[empathy] UOA auth handler: Inform SSO when access token didn't work



commit bad888152af7f4920001f41ffe069ae56d913dc7
Author: Xavier Claessens <xavier claessens collabora co uk>
Date:   Mon Aug 20 17:20:02 2012 +0200

    UOA auth handler: Inform SSO when access token didn't work

 libempathy/empathy-sasl-mechanisms.c  |    1 +
 libempathy/empathy-uoa-auth-handler.c |   68 +++++++++++++++++++++-----------
 2 files changed, 45 insertions(+), 24 deletions(-)
---
diff --git a/libempathy/empathy-sasl-mechanisms.c b/libempathy/empathy-sasl-mechanisms.c
index 316e31b..2857c8b 100644
--- a/libempathy/empathy-sasl-mechanisms.c
+++ b/libempathy/empathy-sasl-mechanisms.c
@@ -87,6 +87,7 @@ sasl_status_changed_cb (TpChannel *channel,
           DEBUG ("SASL failed: %s", error->message);
 
           g_simple_async_result_take_error (result, error);
+          g_simple_async_result_complete (result);
         }
         break;
 
diff --git a/libempathy/empathy-uoa-auth-handler.c b/libempathy/empathy-uoa-auth-handler.c
index 31c1e64..d1b0465 100644
--- a/libempathy/empathy-uoa-auth-handler.c
+++ b/libempathy/empathy-uoa-auth-handler.c
@@ -79,25 +79,6 @@ empathy_uoa_auth_handler_new (void)
   return g_object_new (EMPATHY_TYPE_UOA_AUTH_HANDLER, NULL);
 }
 
-static void
-auth_cb (GObject *source,
-    GAsyncResult *result,
-    gpointer user_data)
-{
-  TpChannel *channel = (TpChannel *) source;
-  GError *error = NULL;
-
-  if (!empathy_sasl_auth_finish (channel, result, &error))
-    {
-      DEBUG ("SASL Mechanism error: %s", error->message);
-      g_clear_error (&error);
-    }
-
-  DEBUG ("Auth on %s suceeded", tp_proxy_get_object_path (channel));
-
-  tp_channel_close_async (channel, NULL, NULL);
-}
-
 typedef struct
 {
   TpChannel *channel;
@@ -137,6 +118,47 @@ query_info_data_free (QueryInfoData *data)
 }
 
 static void
+auth_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  TpChannel *channel = (TpChannel *) source;
+  QueryInfoData *data = user_data;
+  GError *error = NULL;
+
+  if (!empathy_sasl_auth_finish (channel, result, &error))
+    {
+      GHashTable *extra_params;
+
+      DEBUG ("SASL Mechanism error: %s", error->message);
+      g_clear_error (&error);
+
+      /* Inform SSO that the access token didn't work and it should ask user
+       * to re-grant access. */
+      extra_params = tp_asv_new (
+          SIGNON_SESSION_DATA_UI_POLICY, G_TYPE_INT,
+              SIGNON_POLICY_REQUEST_PASSWORD,
+          NULL);
+
+      ag_auth_data_insert_parameters (data->auth_data, extra_params);
+
+      signon_auth_session_process (data->session,
+          ag_auth_data_get_parameters (data->auth_data),
+          ag_auth_data_get_mechanism (data->auth_data),
+          NULL, NULL);
+
+      g_hash_table_unref (extra_params);
+    }
+  else
+    {
+      DEBUG ("Auth on %s suceeded", tp_proxy_get_object_path (channel));
+    }
+
+  tp_channel_close_async (channel, NULL, NULL);
+  query_info_data_free (data);
+}
+
+static void
 session_process_cb (SignonAuthSession *session,
     GHashTable *session_data,
     const GError *error,
@@ -163,26 +185,24 @@ session_process_cb (SignonAuthSession *session,
       case EMPATHY_SASL_MECHANISM_FACEBOOK:
         empathy_sasl_auth_facebook_async (data->channel,
             client_id, access_token,
-            auth_cb, NULL);
+            auth_cb, data);
         break;
 
       case EMPATHY_SASL_MECHANISM_WLM:
         empathy_sasl_auth_wlm_async (data->channel,
             access_token,
-            auth_cb, NULL);
+            auth_cb, data);
         break;
 
       case EMPATHY_SASL_MECHANISM_GOOGLE:
         empathy_sasl_auth_google_async (data->channel,
             data->username, access_token,
-            auth_cb, NULL);
+            auth_cb, data);
         break;
 
       default:
         g_assert_not_reached ();
     }
-
-  query_info_data_free (data);
 }
 
 static void



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