From 862fb161208c72b57cf03cbb2f1a007ce5efeb1d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 11 Jul 2019 14:28:10 -0600 Subject: [PATCH 1/4] Send the correct UIA alongside the wrong UIA for backwards comaptibility Fixes https://github.com/vector-im/riot-web/issues/10312 --- .../views/auth/InteractiveAuthEntryComponents.js | 13 +++++++++++++ .../views/dialogs/DeactivateAccountDialog.js | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/components/views/auth/InteractiveAuthEntryComponents.js b/src/components/views/auth/InteractiveAuthEntryComponents.js index b52dac44a9..f5f61d57cd 100644 --- a/src/components/views/auth/InteractiveAuthEntryComponents.js +++ b/src/components/views/auth/InteractiveAuthEntryComponents.js @@ -91,7 +91,13 @@ export const PasswordAuthEntry = React.createClass({ this.props.submitAuthDict({ type: PasswordAuthEntry.LOGIN_TYPE, + // TODO: Remove `user` once servers support proper UIA + // See https://github.com/vector-im/riot-web/issues/10312 user: this.props.matrixClient.credentials.userId, + identifier: { + type: "m.id.user", + user: this.props.matrixClient.getUserId(), + }, password: this.state.password, }); }, @@ -463,11 +469,18 @@ export const MsisdnAuthEntry = React.createClass({ ); this.props.submitAuthDict({ type: MsisdnAuthEntry.LOGIN_TYPE, + // TODO: Remove `threepid_creds` once servers support proper UIA + // See https://github.com/vector-im/riot-web/issues/10312 threepid_creds: { sid: this._sid, client_secret: this.props.clientSecret, id_server: idServerParsedUrl.host, }, + threepidCreds: { + sid: this._sid, + client_secret: this.props.clientSecret, + id_server: idServerParsedUrl.host, + }, }); } else { this.setState({ diff --git a/src/components/views/dialogs/DeactivateAccountDialog.js b/src/components/views/dialogs/DeactivateAccountDialog.js index cdb5950313..26159523f5 100644 --- a/src/components/views/dialogs/DeactivateAccountDialog.js +++ b/src/components/views/dialogs/DeactivateAccountDialog.js @@ -63,7 +63,13 @@ export default class DeactivateAccountDialog extends React.Component { // for this endpoint. In reality it could be any UI auth. const auth = { type: 'm.login.password', + // TODO: Remove `user` once servers support proper UIA + // See https://github.com/vector-im/riot-web/issues/10312 user: MatrixClientPeg.get().credentials.userId, + identifier: { + type: "m.id.user", + user: MatrixClientPeg.get().credentials.userId, + }, password: this.state.password, }; await MatrixClientPeg.get().deactivateAccount(auth, this.state.shouldErase); From a9419135aade987d613d0669cbb7276f3df11413 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 11 Jul 2019 14:38:28 -0600 Subject: [PATCH 2/4] Fix tests to use UIA proper --- .../components/views/dialogs/InteractiveAuthDialog-test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/components/views/dialogs/InteractiveAuthDialog-test.js b/test/components/views/dialogs/InteractiveAuthDialog-test.js index 2d1fb29bd9..95f76dfd3e 100644 --- a/test/components/views/dialogs/InteractiveAuthDialog-test.js +++ b/test/components/views/dialogs/InteractiveAuthDialog-test.js @@ -97,11 +97,14 @@ describe('InteractiveAuthDialog', function() { ReactTestUtils.Simulate.submit(formNode, {}); expect(doRequest.callCount).toEqual(1); - expect(doRequest.calledWithExactly({ + expect(doRequest.calledWithMatch({ session: "sess", type: "m.login.password", password: "s3kr3t", - user: "@user:id", + identifier: { + type: "m.id.user", + user: "@user:id", + }, })).toBe(true); // let the request complete return Promise.delay(1); From 698fd3b89742b97fd6fdf0680d9ffad2cb4479cd Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 11 Jul 2019 14:45:36 -0600 Subject: [PATCH 3/4] Hopefully actually make the tests happy --- test/components/views/dialogs/InteractiveAuthDialog-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/components/views/dialogs/InteractiveAuthDialog-test.js b/test/components/views/dialogs/InteractiveAuthDialog-test.js index 95f76dfd3e..aa757ce03e 100644 --- a/test/components/views/dialogs/InteractiveAuthDialog-test.js +++ b/test/components/views/dialogs/InteractiveAuthDialog-test.js @@ -97,10 +97,11 @@ describe('InteractiveAuthDialog', function() { ReactTestUtils.Simulate.submit(formNode, {}); expect(doRequest.callCount).toEqual(1); - expect(doRequest.calledWithMatch({ + expect(doRequest.calledWithExactly({ session: "sess", type: "m.login.password", password: "s3kr3t", + user: "@user:id", // TODO: Remove this. See https://github.com/vector-im/riot-web/issues/10312 identifier: { type: "m.id.user", user: "@user:id", From ba5238d86aa896e5dead8cd7c7515f2af5295866 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 11 Jul 2019 15:01:56 -0600 Subject: [PATCH 4/4] Finally fix tests --- src/components/views/auth/InteractiveAuthEntryComponents.js | 2 +- test/components/views/dialogs/InteractiveAuthDialog-test.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/views/auth/InteractiveAuthEntryComponents.js b/src/components/views/auth/InteractiveAuthEntryComponents.js index f5f61d57cd..6e2c31fc55 100644 --- a/src/components/views/auth/InteractiveAuthEntryComponents.js +++ b/src/components/views/auth/InteractiveAuthEntryComponents.js @@ -96,7 +96,7 @@ export const PasswordAuthEntry = React.createClass({ user: this.props.matrixClient.credentials.userId, identifier: { type: "m.id.user", - user: this.props.matrixClient.getUserId(), + user: this.props.matrixClient.credentials.userId, }, password: this.state.password, }); diff --git a/test/components/views/dialogs/InteractiveAuthDialog-test.js b/test/components/views/dialogs/InteractiveAuthDialog-test.js index aa757ce03e..95f76dfd3e 100644 --- a/test/components/views/dialogs/InteractiveAuthDialog-test.js +++ b/test/components/views/dialogs/InteractiveAuthDialog-test.js @@ -97,11 +97,10 @@ describe('InteractiveAuthDialog', function() { ReactTestUtils.Simulate.submit(formNode, {}); expect(doRequest.callCount).toEqual(1); - expect(doRequest.calledWithExactly({ + expect(doRequest.calledWithMatch({ session: "sess", type: "m.login.password", password: "s3kr3t", - user: "@user:id", // TODO: Remove this. See https://github.com/vector-im/riot-web/issues/10312 identifier: { type: "m.id.user", user: "@user:id",