Merge lp:~mardy/ubuntuone-credentials/use-provided-account-1563007 into lp:ubuntuone-credentials

Proposed by Alberto Mardegan
Status: Rejected
Rejected by: Natalia Bidart
Proposed branch: lp:~mardy/ubuntuone-credentials/use-provided-account-1563007
Merge into: lp:ubuntuone-credentials
Diff against target: 202 lines (+55/-14)
9 files modified
debian/changelog (+7/-0)
debian/libubuntuoneauth-2.0-0.symbols (+4/-0)
libubuntuoneauth/keyring.cpp (+12/-1)
libubuntuoneauth/keyring.h (+3/-0)
libubuntuoneauth/ssoservice.cpp (+10/-0)
libubuntuoneauth/ssoservice.h (+3/-0)
online-accounts-provider/NewAccount.qml (+1/-13)
qml-credentials-service/ubuntuone_credentials_service.cpp (+10/-0)
qml-credentials-service/ubuntuone_credentials_service.h (+5/-0)
To merge this branch: bzr merge lp:~mardy/ubuntuone-credentials/use-provided-account-1563007
Reviewer Review Type Date Requested Status
unity-api-1-bot continuous-integration Needs Fixing
dobey (community) Needs Information
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+290429@code.launchpad.net

Commit message

Use account object provided by online-accounts-ui

Without this change, the creation of UbuntuOne accounts gets reported as a failure, because the value of "account.accountId" never gets changed, since the UbuntuOne::Keyring is creating a different account.
This change also fixes the account creation in System Settings: before, once a new account was created the view switched back to the list of account providers; now, it properly switches back to the list of accounts.

Description of the change

Use account object provided by online-accounts-ui

Without this change, the creation of UbuntuOne accounts gets reported as a failure, because the value of "account.accountId" never gets changed, since the UbuntuOne::Keyring is creating a different account.
This change also fixes the account creation in System Settings: before, once a new account was created the view switched back to the list of account providers; now, it properly switches back to the list of accounts.

To post a comment you must log in.
Revision history for this message
dobey (dobey) wrote :

I do not understand what this is meant to fix exactly, or why adding API is a reasonable solution for it. We have been using the account object provided by OA for a long time now, so this can't possibly simply be doing that.

AFAICT, this is a rushed workaround for a problem that is not well understood.

review: Needs Information
234. By Alberto Mardegan

Update bug number

Revision history for this message
Alberto Mardegan (mardy) wrote :

While I initially claimed that this change would fix bug 1563007 (which it doesn't), the MP description is correct.
I've now filed a different bug to better explain what this change fixes, and updated the changelog accordingly.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) wrote :

As per discussion on the bug, this seems like perhaps a bug in ussoa instead, when there are existing accounts, as the problem doesn't occur when U1 is the first account being added, only when there are other accounts already existing.

Let's try to figure out what actually changed or is going on, before moving any further here, as I'd rather avoid adding some obtuse API to work around an issue that exists elsewhere.

review: Needs Information
Revision history for this message
Alberto Mardegan (mardy) wrote :

On 20/04/2016 20:45, Rodney Dawes wrote:
> Review: Needs Information
>
> Let's try to figure out what actually changed or is going on, before moving any further here, as I'd rather avoid adding some obtuse API to work around an issue that exists elsewhere.

I've investigated this, and I'm not sure we have a bug, after all.
When the Online Accounts page is opened from the System Settings, we
bind to the accountsModel.count property to decide whether to show the
NoAccountsPage (the one with the explanatory text and the list of
accounts providers) or the AccountsPage (which lists your existing
accounts).

It's a property binding, meaning that if an account is created (even by
an external app) while you are in the NoAccountsPage, the view will
switch to the AccountsPage; and conversely, if you are in the
AccountsPage and all accounts get deleted (even by an external app), the
view will switch to the NoAccountsPage. I think that this is the correct
behaviour.

So, back to our issue: when you create the U1 account as your first
account, the account creation won't be considered successful by ussoa
(due to this bug about another account object being modified), but you
are still writing the account to the database, so the account model is
getting its "count" property increased to 1 and the view will switch.

So, this is not really an issue, and we should not worry about it.

Now, I understand that you don't like changing the public API, so here's
my suggestions:

1) HACK: we don't add a public API, and the QML plugin will set the
account as a dynamic QObject property on the SsoService:

    ssoService->setProperty("_u1_account", account);

and the keyring will fetch it from the ssoService with

    account = ssoService->property("_u1_account");

It's a hack, but it's not that bad since it's contained in a single
project and it can go away when we switch to #2 below.

2) Once we have the U1 signon authentication plugin, we can modify the
account plugin not to talk to libubuntuoneauth at all, and instead
create the account directly using the OA QML APIs, like the OAuth plugin
is doing.

Revision history for this message
dobey (dobey) wrote :

I wonder what broke this then. We previously did a fair bit of work to use the existing account provided by OA, to fix a previous issue similar to this. It was working fine for quite some time, so I wonder what broke, because we haven't changed anything in u1-credentials that would be related to this, for quite a while now.

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Started a massive cleanup of old MPs, closing this given its age, please update and re-open if still valid.

Unmerged revisions

234. By Alberto Mardegan

Update bug number

233. By Alberto Mardegan

Use account object provided by OA

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-03-23 19:31:42 +0000
3+++ debian/changelog 2016-03-30 13:47:05 +0000
4@@ -1,3 +1,10 @@
5+ubuntuone-credentials (15.11+16.04.20160330) vivid; urgency=medium
6+
7+ * debian/libubuntuoneauth-2.0-0.symbols: update to released version.
8+ * Use account object provided by OA (LP: #1563867)
9+
10+ -- Alberto Mardegan <alberto.mardegan@canonical.com> Wed, 30 Mar 2016 12:33:36 +0300
11+
12 ubuntuone-credentials (15.11+16.04.20160323) xenial; urgency=medium
13
14 [ CI Train Bot ]
15
16=== modified file 'debian/libubuntuoneauth-2.0-0.symbols'
17--- debian/libubuntuoneauth-2.0-0.symbols 2015-12-07 21:38:01 +0000
18+++ debian/libubuntuoneauth-2.0-0.symbols 2016-03-30 13:47:05 +0000
19@@ -15,6 +15,8 @@
20 (c++)"UbuntuOne::AuthLogger::~AuthLogger()@Base" 13.08
21 (c++)"UbuntuOne::SSOService::qt_metacall(QMetaObject::Call, int, void**)@Base" 13.08
22 (c++)"UbuntuOne::SSOService::qt_metacast(char const*)@Base" 13.08
23+ (c++)"UbuntuOne::SSOService::setAccount(QObject*)@Base" 15.11+16.04.20160330
24+ (c++)"UbuntuOne::SSOService::account() const@Base" 15.11+16.04.20160330
25 (c++)"UbuntuOne::SSOService::registerUser(QString, QString, QString)@Base" 13.08
26 (c++)"UbuntuOne::SSOService::accountPinged(QNetworkReply*)@Base" 13.08
27 (c++)"UbuntuOne::SSOService::errorOccurred(UbuntuOne::ErrorResponse const&)@Base" 13.08
28@@ -116,6 +118,8 @@
29 (c++)"UbuntuOne::Token::updated() const@Base" 14.04+14.10.20140818
30 (c++)"UbuntuOne::Token::getServerTimestamp() const@Base" 15.11+16.04.20151207.1
31 (c++)"UbuntuOne::Token::addOAuthTimestamp(QString) const@Base" 15.11+16.04.20151207.1
32+ (c++)"UbuntuOne::Keyring::setAccount(QObject*)@Base" 15.11+16.04.20160330
33+ (c++)"UbuntuOne::Keyring::account() const@Base" 15.11+16.04.20160330
34 (c++)"UbuntuOne::Keyring::storeToken(UbuntuOne::Token)@Base" 13.08
35 (c++)"UbuntuOne::Keyring::storeToken(UbuntuOne::Token, QString const&)@Base" 14.04+14.10.20140802
36 (c++)"UbuntuOne::Keyring::tokenFound(UbuntuOne::Token const&)@Base" 13.08
37
38=== modified file 'libubuntuoneauth/keyring.cpp'
39--- libubuntuoneauth/keyring.cpp 2015-03-12 13:13:46 +0000
40+++ libubuntuoneauth/keyring.cpp 2016-03-30 13:47:05 +0000
41@@ -38,6 +38,16 @@
42 _account = nullptr;
43 }
44
45+ void Keyring::setAccount(QObject *account)
46+ {
47+ _account = qobject_cast<Accounts::Account*>(account);
48+ }
49+
50+ QObject *Keyring::account() const
51+ {
52+ return _account;
53+ }
54+
55 void Keyring::handleError(const SignOn::Error &error)
56 {
57 qCritical() << "Error:" << error.message();
58@@ -103,7 +113,6 @@
59 void Keyring::handleCredentialsStored(const quint32 id)
60 {
61 QString _acctName("ubuntuone");
62- AccountIdList _ids = _manager.accountList(_acctName);
63
64 _account->selectService();
65 _account->setCredentialsId(id);
66@@ -133,6 +142,8 @@
67 }
68 _account = _manager.account(_ids[0]);
69 qDebug() << "storeToken(): Using Ubuntu One account '" << _ids[0] << "'.";
70+ } else if (_account) {
71+ qDebug() << "storeToken(): using provided account";
72 } else {
73 qDebug() << "in storeToken(): no accounts found in accountList, creating new";
74 _account = _manager.createAccount(_acctName);
75
76=== modified file 'libubuntuoneauth/keyring.h'
77--- libubuntuoneauth/keyring.h 2015-01-16 22:09:15 +0000
78+++ libubuntuoneauth/keyring.h 2016-03-30 13:47:05 +0000
79@@ -35,6 +35,9 @@
80 public:
81 explicit Keyring(QObject *parent=NULL);
82
83+ void setAccount(QObject *account);
84+ QObject *account() const;
85+
86 void findToken();
87 void storeToken(Token token);
88 void storeToken(Token token, const QString& displayName);
89
90=== modified file 'libubuntuoneauth/ssoservice.cpp'
91--- libubuntuoneauth/ssoservice.cpp 2015-01-15 21:12:35 +0000
92+++ libubuntuoneauth/ssoservice.cpp 2016-03-30 13:47:05 +0000
93@@ -77,6 +77,16 @@
94 this, SLOT(errorOccurred(const ErrorResponse&)));
95 }
96
97+ void SSOService::setAccount(QObject *account)
98+ {
99+ _keyring->setAccount(account);
100+ }
101+
102+ QObject *SSOService::account() const
103+ {
104+ return _keyring->account();
105+ }
106+
107 void SSOService::getCredentials()
108 {
109 _keyring->findToken();
110
111=== modified file 'libubuntuoneauth/ssoservice.h'
112--- libubuntuoneauth/ssoservice.h 2015-01-15 21:12:35 +0000
113+++ libubuntuoneauth/ssoservice.h 2016-03-30 13:47:05 +0000
114@@ -38,6 +38,9 @@
115 public:
116 explicit SSOService(QObject *parent = 0);
117
118+ void setAccount(QObject *account);
119+ QObject *account() const;
120+
121 void invalidateCredentials();
122 void getCredentials();
123 void login(QString email, QString password, QString twoFactorCode = QString());
124
125=== modified file 'online-accounts-provider/NewAccount.qml'
126--- online-accounts-provider/NewAccount.qml 2016-03-21 14:48:41 +0000
127+++ online-accounts-provider/NewAccount.qml 2016-03-30 13:47:05 +0000
128@@ -117,6 +117,7 @@
129
130 UbuntuOneCredentialsService {
131 id: u1credservice
132+ account: __account.objectHandle
133
134 onLoginOrRegisterSuccess: {
135 handleSuccess();
136@@ -252,17 +253,4 @@
137 errorLabel.visible = false;
138 }
139 }
140-
141- Component {
142- id: accountServiceComponent
143- AccountService {
144- autoSync: false
145- }
146- }
147-
148- AccountServiceModel {
149- id: accountServices
150- includeDisabled: true
151- account: __account.objectHandle
152- }
153 }
154
155=== modified file 'qml-credentials-service/ubuntuone_credentials_service.cpp'
156--- qml-credentials-service/ubuntuone_credentials_service.cpp 2013-11-05 14:53:04 +0000
157+++ qml-credentials-service/ubuntuone_credentials_service.cpp 2016-03-30 13:47:05 +0000
158@@ -26,6 +26,16 @@
159 {
160 }
161
162+void UbuntuOneCredentialsService::setAccount(QObject *account)
163+{
164+ _service.setAccount(account);
165+ Q_EMIT accountChanged();
166+}
167+
168+QObject *UbuntuOneCredentialsService::account() const
169+{
170+ return _service.account();
171+}
172
173 // public API (Q_INVOKABLE)
174
175
176=== modified file 'qml-credentials-service/ubuntuone_credentials_service.h'
177--- qml-credentials-service/ubuntuone_credentials_service.h 2013-07-12 17:53:20 +0000
178+++ qml-credentials-service/ubuntuone_credentials_service.h 2016-03-30 13:47:05 +0000
179@@ -19,11 +19,15 @@
180 {
181 Q_OBJECT
182 Q_DISABLE_COPY(UbuntuOneCredentialsService)
183+ Q_PROPERTY(QObject *account READ account WRITE setAccount NOTIFY accountChanged)
184
185 public:
186 UbuntuOneCredentialsService(QQuickItem *parent = 0);
187 ~UbuntuOneCredentialsService();
188
189+ void setAccount(QObject *account);
190+ QObject *account() const;
191+
192 Q_INVOKABLE void checkCredentials();
193 Q_INVOKABLE void invalidateCredentials();
194 Q_INVOKABLE void login(QString email, QString password, QString twoFactorCode = QString());
195@@ -31,6 +35,7 @@
196 Q_INVOKABLE void signUrl(QString url, QString method, bool asQuery = false);
197
198 signals:
199+ void accountChanged();
200 void credentialsFound();
201 void credentialsNotFound();
202 void credentialsDeleted();

Subscribers

People subscribed via source and target branches