[gnome-maps/wip/mlundblad/handle-libsecret-fail: 19/19] osmAccountDialog, osmConnection: Show error message when store failed




commit 692f961d178939711e537c62e437ee2128f8bc2e
Author: Marcus Lundblad <ml update uu se>
Date:   Fri May 7 23:17:16 2021 +0200

    osmAccountDialog, osmConnection: Show error message when store failed
    
    Show error message when secret store fails.

 src/osmAccountDialog.js |  5 ++++-
 src/osmConnection.js    | 12 +++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/osmAccountDialog.js b/src/osmAccountDialog.js
index c93cad27..d522e456 100644
--- a/src/osmAccountDialog.js
+++ b/src/osmAccountDialog.js
@@ -25,6 +25,7 @@ const Gtk = imports.gi.Gtk;
 const WebKit2 = imports.gi.WebKit2;
 
 const Application = imports.application;
+const Utils = imports.utils;
 
 var Response = {
     SIGNED_IN: 0
@@ -181,7 +182,7 @@ var OSMAccountDialog = GObject.registerClass({
             this._performVerification();
     }
 
-    _onOAuthAccessTokenRequested(success) {
+    _onOAuthAccessTokenRequested(success, errorMessage) {
         if (success) {
             /* update the username label */
             this._signedInUserLabel.label = Application.osmEdit.username;
@@ -197,6 +198,8 @@ var OSMAccountDialog = GObject.registerClass({
                 this._stack.visible_child_name = 'logged-in';
             }
         } else {
+            if (errorMessage)
+                Utils.showDialog(errorMessage, Gtk.MessageType.ERROR, this);
             /* switch back to the sign-in view, and show a label indicating
                that verification failed */
             this._resetPasswordLabel.visible = false;
diff --git a/src/osmConnection.js b/src/osmConnection.js
index 7cbee11d..eb84287b 100644
--- a/src/osmConnection.js
+++ b/src/osmConnection.js
@@ -364,9 +364,15 @@ var OSMConnection = class OSMConnection {
 
     _onPasswordStored(result, callback) {
         let res = false;
-        if (result)
-            res = Secret.password_store_finish(result);
-        callback(res);
+        let errorMessage;
+        if (result) {
+            try {
+                res = Secret.password_store_finish(result);
+            } catch (error) {
+                errorMessage = error.message;
+            }
+        }
+        callback(res, errorMessage);
     }
 
     signOut() {


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