Merge lp:~mardy/gnome-control-center-signon/update-params into lp:gnome-control-center-signon

Proposed by Alberto Mardegan on 2012-09-10
Status: Merged
Approved by: David King on 2012-09-10
Approved revision: 100
Merged at revision: 100
Proposed branch: lp:~mardy/gnome-control-center-signon/update-params
Merge into: lp:gnome-control-center-signon
Diff against target: 58 lines (+34/-1)
1 file modified
libaccount-plugin/oauth-plugin.c (+34/-1)
To merge this branch: bzr merge lp:~mardy/gnome-control-center-signon/update-params
Reviewer Review Type Date Requested Status
David King (community) 2012-09-10 Approve on 2012-09-10
jenkins (community) continuous-integration Needs Fixing on 2012-09-10
Review via email: mp+123528@code.launchpad.net

Description of the change

OAuthPlugin: update authentication parameters on re-authentication

To post a comment you must log in.
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
David King (amigadave) wrote :

The Jenkins failure is just a conflict in configure.ac; the tests all build and pass fine here. Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libaccount-plugin/oauth-plugin.c'
2--- libaccount-plugin/oauth-plugin.c 2012-09-06 15:45:33 +0000
3+++ libaccount-plugin/oauth-plugin.c 2012-09-10 11:23:22 +0000
4@@ -163,6 +163,27 @@
5 }
6
7 static void
8+unset_authentication_settings (AgAccount *account,
9+ const gchar *method,
10+ const gchar *mechanism)
11+{
12+ AgAccountSettingIter iter;
13+ const gchar *key;
14+ const GValue *value;
15+ gchar *prefix, *full_key;
16+
17+ prefix = g_strdup_printf ("auth/%s/%s/", method, mechanism);
18+ ag_account_settings_iter_init (account, &iter, prefix);
19+ while (ag_account_settings_iter_next (&iter, &key, &value))
20+ {
21+ full_key = g_strconcat (prefix, key, NULL);
22+ ag_account_set_value (account, full_key, NULL);
23+ g_free (full_key);
24+ }
25+ g_free (prefix);
26+}
27+
28+static void
29 store_authentication_parameters (ApOAuthPlugin *self, AgAccount *account)
30 {
31 ApOAuthPluginPrivate *priv = self->priv;
32@@ -188,6 +209,13 @@
33 g_value_set_static_string (&v_mechanism, priv->mechanism);
34 ag_account_set_value (account, "auth/mechanism", &v_mechanism);
35
36+ /* Delete any existing parameter (if the account is not new) */
37+ if (account->id != 0)
38+ {
39+ unset_authentication_settings (account,
40+ oauth_method, priv->mechanism);
41+ }
42+
43 /* Add all the provider-specific OAuth parameters. */
44 parameters = priv->account_oauth_params != NULL ?
45 priv->account_oauth_params : priv->oauth_params;
46@@ -282,7 +310,12 @@
47 {
48 /* re-authenticated account */
49 ap_plugin_set_need_authentication ((ApPlugin *)self, FALSE);
50- g_idle_add ((GSourceFunc)emit_finished, self);
51+
52+ /* Store the authentication parameters, in case they have changed.
53+ * This might be removed or reviewed once the following is implemented:
54+ * http://code.google.com/p/accounts-sso/issues/detail?id=111
55+ */
56+ store_account (self);
57 }
58 }
59

Subscribers

People subscribed via source and target branches