[geary/wip/fix-not-prompting-for-missing-password: 3/4] Ensure GOA accounts have their creds updated after the account itself is



commit 938baa0a1296c015aa53a6e4eca2b66e4181c17c
Author: Michael Gratton <mike vee net>
Date:   Thu Feb 21 15:43:47 2019 +1100

    Ensure GOA accounts have their creds updated after the account itself is
    
    This prevents spurious auth failures when GOA flags an account has been
    updated (probably due to a token update anyway).
    
    Fixes #250 (likely)

 src/client/accounts/accounts-manager.vala | 45 ++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 19 deletions(-)
---
diff --git a/src/client/accounts/accounts-manager.vala b/src/client/accounts/accounts-manager.vala
index 426cb28a..b9b447e8 100644
--- a/src/client/accounts/accounts-manager.vala
+++ b/src/client/accounts/accounts-manager.vala
@@ -828,6 +828,31 @@ public class Accounts.Manager : GLib.Object {
         }
     }
 
+    private async void update_goa_account(Geary.AccountInformation account,
+                                          GLib.Cancellable? cancellable) {
+        GoaMediator mediator = (GoaMediator) account.mediator;
+        try {
+            yield mediator.update(account, cancellable);
+
+            // Update will clear the creds, so make sure they get
+            // refreshed
+            yield account.load_outgoing_credentials(cancellable);
+            yield account.load_incoming_credentials(cancellable);
+        } catch (GLib.Error err) {
+            report_problem(
+                new Geary.AccountProblemReport(
+                    Geary.ProblemType.GENERIC_ERROR,
+                    account,
+                    err
+                ));
+        }
+
+        // XXX need to notify the engine that creds may have changed
+
+        set_available(account, mediator.is_available);
+    }
+
+
     private async void open_goa_settings(string action,
                                          string? param,
                                          GLib.Cancellable? cancellable)
@@ -894,25 +919,7 @@ public class Accounts.Manager : GLib.Object {
             // We already know about this account, so check that it is
             // still valid. If not, the account should be disabled,
             // not deleted, since it may be re-enabled at some point.
-            GoaMediator mediator = (GoaMediator) state.account.mediator;
-            mediator.update.begin(
-                state.account,
-                null, // XXX Get a cancellable to this somehow
-                (obj, res) => {
-                    try {
-                        mediator.update.end(res);
-                    } catch (GLib.Error err) {
-                        report_problem(
-                            new Geary.AccountProblemReport(
-                                Geary.ProblemType.GENERIC_ERROR,
-                                state.account,
-                                err
-                            ));
-                    }
-
-                    set_available(state.account, mediator.is_available);
-                }
-            );
+            this.update_goa_account.begin(state.account, null);
         } else {
             // We haven't created an account for this GOA account
             // before, so try doing so now.


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