[polari] util: Add helper functions to clear account/identify passwords



commit 8c15ba092612134d3e6263f58ed6b336ebb8660c
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Apr 5 00:41:34 2020 +0200

    util: Add helper functions to clear account/identify passwords
    
    https://gitlab.gnome.org/GNOME/polari/-/issues/132

 src/utils.js | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/utils.js b/src/utils.js
index 5abe1b93..4931024f 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -1,7 +1,8 @@
 /* exported isFlatpakSandbox touchFile needsOnetimeAction getTpEventTime
             findUrls findChannels openURL updateTerms gpaste imgurPaste
             storeAccountPassword storeIdentifyPassword
-            lookupAccountPassword lookupIdentifyPassword */
+            lookupAccountPassword lookupIdentifyPassword
+            clearAccountPassword clearIdentifyPassword */
 /*
  * Copyright (c) 2011 Red Hat, Inc.
  *
@@ -177,6 +178,26 @@ function _lookupPassword(schema, account, callback) {
     });
 }
 
+function clearAccountPassword(account) {
+    _clearPassword(SECRET_SCHEMA_ACCOUNT, account);
+}
+
+function clearIdentifyPassword(account) {
+    _clearPassword(SECRET_SCHEMA_IDENTIFY, account);
+}
+
+function _clearPassword(schema, account) {
+    let attr = { 'account-id': account.get_path_suffix() };
+    Secret.password_clear(schema, attr, null, (o, res) => {
+        try {
+            Secret.password_clear_finish(res);
+        } catch (e) {
+            const name = account.display_name;
+            log(`Failed to clear password for account "${name}": ${e.message}`);
+        }
+    });
+}
+
 // findUrls:
 // @str: string to find URLs in
 //


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]