Merge lp:~mardy/account-plugins/no-duplicates-1468599 into lp:account-plugins

Proposed by Alberto Mardegan on 2016-01-22
Status: Merged
Approved by: David Barth on 2016-02-09
Approved revision: 154
Merged at revision: 154
Proposed branch: lp:~mardy/account-plugins/no-duplicates-1468599
Merge into: lp:account-plugins
Diff against target: 78 lines (+18/-16)
2 files modified
qml/facebook/Main.qml (+14/-10)
qml/google/Main.qml (+4/-6)
To merge this branch: bzr merge lp:~mardy/account-plugins/no-duplicates-1468599
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2016-01-22
Online Accounts 2016-01-22 Pending
Review via email: mp+283620@code.launchpad.net

Commit message

Use the new methods to retrieve the username.

Description of the change

Use the new methods to retrieve the username.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/facebook/Main.qml'
2--- qml/facebook/Main.qml 2015-04-10 05:37:48 +0000
3+++ qml/facebook/Main.qml 2016-01-22 15:00:31 +0000
4@@ -2,7 +2,9 @@
5
6 OAuthMain {
7 creationComponent: OAuth {
8- function completeCreation(reply) {
9+ property var __meData
10+
11+ function getUserName(reply, callback) {
12 console.log("Access token: " + reply.AccessToken)
13 var http = new XMLHttpRequest()
14 var url = "https://graph.facebook.com/me?access_token=" + reply.AccessToken;
15@@ -12,22 +14,24 @@
16 if (http.status == 200) {
17 console.log("ok")
18 console.log("response text: " + http.responseText)
19- var response = JSON.parse(http.responseText)
20- account.updateDisplayName(response.name)
21- globalAccountService.updateSettings({
22- 'id': response.id
23- })
24- account.synced.connect(finished)
25- account.sync()
26-
27+ __meData = JSON.parse(http.responseText)
28+ callback(__meData.name)
29+ return true
30 } else {
31 console.log("error: " + http.status)
32- cancel()
33+ return false
34 }
35 }
36 };
37
38 http.send(null);
39 }
40+
41+ function beforeSaving(reply) {
42+ globalAccountService.updateSettings({
43+ 'id': __meData.id
44+ })
45+ saveAccount()
46+ }
47 }
48 }
49
50=== modified file 'qml/google/Main.qml'
51--- qml/google/Main.qml 2013-06-26 11:54:11 +0000
52+++ qml/google/Main.qml 2016-01-22 15:00:31 +0000
53@@ -6,7 +6,7 @@
54 "AuthPath": "o/oauth2/auth?access_type=offline&approval_prompt=force"
55 }
56
57- function completeCreation(reply) {
58+ function getUserName(reply, callback) {
59 console.log("Access token: " + reply.AccessToken)
60 var http = new XMLHttpRequest()
61 var url = "https://www.googleapis.com/oauth2/v3/userinfo";
62@@ -18,13 +18,11 @@
63 console.log("ok")
64 console.log("response text: " + http.responseText)
65 var response = JSON.parse(http.responseText)
66- account.updateDisplayName(response.email)
67- account.synced.connect(finished)
68- account.sync()
69-
70+ callback(response.email)
71+ return true
72 } else {
73 console.log("error: " + http.status)
74- cancel()
75+ return false
76 }
77 }
78 };

Subscribers

People subscribed via source and target branches

to all changes: