[gnome-online-accounts] Handle failures to store credentials in the keyring in a better way



commit b6259c058d6c9887ab84201c59305ee741b61b48
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Apr 16 18:46:16 2012 +0200

    Handle failures to store credentials in the keyring in a better way
    
    Allow the object to be created even if we failed to store the
    credentials in the keyring. When an application tries to lookup the
    credentials and does not find it, the user will be prompted to refresh
    the account manually.
    
    Fixes: https://bugzilla.gnome.org/674165

 src/goabackend/goaoauth2provider.c |   12 +++++-------
 src/goabackend/goaoauthprovider.c  |   12 +++++-------
 src/goabackend/goaprovider.c       |    4 +++-
 3 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c
index 9640e3b..8dbbc0f 100644
--- a/src/goabackend/goaoauth2provider.c
+++ b/src/goabackend/goaoauth2provider.c
@@ -1100,15 +1100,13 @@ goa_oauth2_provider_add_account (GoaProvider *_provider,
     goto out;
 
  out:
+  /* We might have an object even when data.error is set.
+   * eg., if we failed to store the credentials in the keyring.
+   */
   if (data.error != NULL)
-    {
-      g_propagate_error (error, data.error);
-      g_assert (ret == NULL);
-    }
+    g_propagate_error (error, data.error);
   else
-    {
-      g_assert (ret != NULL);
-    }
+    g_assert (ret != NULL);
 
   g_list_foreach (accounts, (GFunc) g_object_unref, NULL);
   g_list_free (accounts);
diff --git a/src/goabackend/goaoauthprovider.c b/src/goabackend/goaoauthprovider.c
index 01b8462..b99038f 100644
--- a/src/goabackend/goaoauthprovider.c
+++ b/src/goabackend/goaoauthprovider.c
@@ -1104,15 +1104,13 @@ goa_oauth_provider_add_account (GoaProvider *_provider,
     goto out;
 
  out:
+  /* We might have an object even when data.error is set.
+   * eg., if we failed to store the credentials in the keyring.
+   */
   if (data.error != NULL)
-    {
-      g_propagate_error (error, data.error);
-      g_assert (ret == NULL);
-    }
+    g_propagate_error (error, data.error);
   else
-    {
-      g_assert (ret != NULL);
-    }
+    g_assert (ret != NULL);
 
   g_list_foreach (accounts, (GFunc) g_object_unref, NULL);
   g_list_free (accounts);
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 6d1db56..ba74922 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -187,7 +187,9 @@ goa_provider_get_provider_icon_default (GoaProvider *provider,
  * If an account was successfully created, a #GoaObject for the
  * created account is returned. If @dialog is dismissed, %NULL is
  * returned and @error is set to %GOA_ERROR_DIALOG_DISMISSED. If an
- * account couldn't be created then @error is set.
+ * account couldn't be created then @error is set. In some cases,
+ * for example, when the credentials could not be stored in the
+ * keyring, a #GoaObject can be returned even if @error is set.
  *
  * The caller will always show an error dialog if @error is set unless
  * the error is %GOA_ERROR_DIALOG_DISMISSED.



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