[polari/gnome-3-36] util: Add helper functions to clear account/identify passwords



commit 1c151fb4290ab702faff6fba09daab48ccd38a85
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 1bd3b025..dd2286a9 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -1,7 +1,8 @@
 /* exported isFlatpakSandbox getTpEventTime findUrls findChannels openURL
             storeAccountPassword storeIdentifyPassword
             lookupAccountPassword lookupIdentifyPassword
-            updateTerms gpaste imgurPaste */
+            updateTerms gpaste imgurPaste
+            clearAccountPassword clearIdentifyPassword */
 /*
  * Copyright (c) 2011 Red Hat, Inc.
  *
@@ -147,6 +148,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]