From 48b80449376f41e69fe8434a5ada96d9dc4a1ee2 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 7 Oct 2019 17:43:17 +0200 Subject: [PATCH 1/6] don't try to get id server domain when not asked to bind --- src/AddThreepid.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/AddThreepid.js b/src/AddThreepid.js index 8f19815210c..dde0fbcbc90 100644 --- a/src/AddThreepid.js +++ b/src/AddThreepid.js @@ -20,6 +20,10 @@ import MatrixClientPeg from './MatrixClientPeg'; import { _t } from './languageHandler'; import IdentityAuthClient from './IdentityAuthClient'; +function getIdServerDomain() { + return MatrixClientPeg.get().idBaseUrl.split("://")[1]; +} + /** * Allows a user to add a third party identifier to their homeserver and, * optionally, the identity servers. @@ -155,7 +159,6 @@ export default class AddThreepid { * the request failed. */ async checkEmailLinkClicked() { - const identityServerDomain = MatrixClientPeg.get().idBaseUrl.split("://")[1]; try { if (await MatrixClientPeg.get().doesServerSupportSeparateAddAndBind()) { if (this.bind) { @@ -164,7 +167,7 @@ export default class AddThreepid { await MatrixClientPeg.get().bindThreePid({ sid: this.sessionId, client_secret: this.clientSecret, - id_server: identityServerDomain, + id_server: getIdServerDomain(), id_access_token: identityAccessToken, }); } else { @@ -177,7 +180,7 @@ export default class AddThreepid { await MatrixClientPeg.get().addThreePid({ sid: this.sessionId, client_secret: this.clientSecret, - id_server: identityServerDomain, + id_server: getIdServerDomain(), }, this.bind); } } catch (err) { From 040bc5e1576f369f07ec29ad9c1c0497202d28ff Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 7 Oct 2019 17:43:51 +0200 Subject: [PATCH 2/6] show dialog when server says e-mail hasn't been verified yet as it's confusing to have nothing happen at all when clicking continue straight away. --- .../views/settings/account/EmailAddresses.js | 10 ++++++++-- src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/account/EmailAddresses.js b/src/components/views/settings/account/EmailAddresses.js index 30fc805f6d4..e50039d0b6d 100644 --- a/src/components/views/settings/account/EmailAddresses.js +++ b/src/components/views/settings/account/EmailAddresses.js @@ -193,8 +193,14 @@ export default class EmailAddresses extends React.Component { this.props.onEmailsChange(emails); }).catch((err) => { this.setState({continueDisabled: false}); - if (err.errcode !== 'M_THREEPID_AUTH_FAILED') { - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + if (err.errcode === 'M_THREEPID_AUTH_FAILED') { + Modal.createTrackedDialog("Email hasn't been verified yet", "", ErrorDialog, { + title: _t("Your email address hasn't been verified yet"), + description: _t("Click the link in the email you received to verify, " + + "and then click continue again."), + }); + } else { console.error("Unable to verify email address: " + err); Modal.createTrackedDialog('Unable to verify email address', '', ErrorDialog, { title: _t("Unable to verify email address."), diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index fc094f48f62..74502444b8a 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -759,6 +759,8 @@ "Invalid Email Address": "Invalid Email Address", "This doesn't appear to be a valid email address": "This doesn't appear to be a valid email address", "Unable to add email address": "Unable to add email address", + "Your e-mail address hasn't been verified yet": "Your e-mail address hasn't been verified yet", + "Click the link in the e-mail you received to verify, and then click continue again.": "Click the link in the e-mail you received to verify, and then click continue again.", "Add": "Add", "We've sent you an email to verify your address. Please follow the instructions there and then click the button below.": "We've sent you an email to verify your address. Please follow the instructions there and then click the button below.", "Email Address": "Email Address", From 978866ea960635fb125f45311c1dbd0b2183a0ad Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Oct 2019 08:43:40 +0200 Subject: [PATCH 3/6] dont assume id server when verifying phone numbers either --- src/AddThreepid.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/AddThreepid.js b/src/AddThreepid.js index dde0fbcbc90..f0781e26e95 100644 --- a/src/AddThreepid.js +++ b/src/AddThreepid.js @@ -224,13 +224,12 @@ export default class AddThreepid { throw result; } - const identityServerDomain = MatrixClientPeg.get().idBaseUrl.split("://")[1]; if (await MatrixClientPeg.get().doesServerSupportSeparateAddAndBind()) { if (this.bind) { await MatrixClientPeg.get().bindThreePid({ sid: this.sessionId, client_secret: this.clientSecret, - id_server: identityServerDomain, + id_server: getIdServerDomain(), id_access_token: await authClient.getAccessToken(), }); } else { @@ -243,7 +242,7 @@ export default class AddThreepid { await MatrixClientPeg.get().addThreePid({ sid: this.sessionId, client_secret: this.clientSecret, - id_server: identityServerDomain, + id_server: getIdServerDomain(), }, this.bind); } } From 1ab19be46c38f7f885ea568ff730031dad390778 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Oct 2019 08:50:17 +0200 Subject: [PATCH 4/6] also show dialog here unsure why this code seems duplicated? --- .../views/settings/discovery/EmailAddresses.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/discovery/EmailAddresses.js b/src/components/views/settings/discovery/EmailAddresses.js index a4fcd605fc6..b83701cbed2 100644 --- a/src/components/views/settings/discovery/EmailAddresses.js +++ b/src/components/views/settings/discovery/EmailAddresses.js @@ -171,8 +171,14 @@ export class EmailAddress extends React.Component { }); } catch (err) { this.setState({ continueDisabled: false }); - if (err.errcode !== 'M_THREEPID_AUTH_FAILED') { - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + if (err.errcode === 'M_THREEPID_AUTH_FAILED') { + Modal.createTrackedDialog("E-mail hasn't been verified yet", "", ErrorDialog, { + title: _t("Your email address hasn't been verified yet"), + description: _t("Click the link in the email you received to verify, " + + "and then click continue again."), + }); + } else { console.error("Unable to verify email address: " + err); Modal.createTrackedDialog('Unable to verify email address', '', ErrorDialog, { title: _t("Unable to verify email address."), From cbeb45abd368a99cfee12722eb76e19927a91e98 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Oct 2019 08:56:34 +0200 Subject: [PATCH 5/6] update i18n --- src/i18n/strings/en_EN.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 74502444b8a..ba0fbf628e5 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -740,6 +740,8 @@ "Who can read history?": "Who can read history?", "Unable to revoke sharing for email address": "Unable to revoke sharing for email address", "Unable to share email address": "Unable to share email address", + "Your email address hasn't been verified yet": "Your email address hasn't been verified yet", + "Click the link in the email you received to verify, and then click continue again.": "Click the link in the email you received to verify, and then click continue again.", "Unable to verify email address.": "Unable to verify email address.", "Verify the link in your inbox": "Verify the link in your inbox", "Complete": "Complete", @@ -759,8 +761,6 @@ "Invalid Email Address": "Invalid Email Address", "This doesn't appear to be a valid email address": "This doesn't appear to be a valid email address", "Unable to add email address": "Unable to add email address", - "Your e-mail address hasn't been verified yet": "Your e-mail address hasn't been verified yet", - "Click the link in the e-mail you received to verify, and then click continue again.": "Click the link in the e-mail you received to verify, and then click continue again.", "Add": "Add", "We've sent you an email to verify your address. Please follow the instructions there and then click the button below.": "We've sent you an email to verify your address. Please follow the instructions there and then click the button below.", "Email Address": "Email Address", From 8c8b1430e48560ff8571370358057c0ab041964e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Oct 2019 18:39:35 +0200 Subject: [PATCH 6/6] fix spelling --- src/components/views/settings/account/EmailAddresses.js | 2 +- src/components/views/settings/discovery/EmailAddresses.js | 2 +- src/i18n/strings/en_EN.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/settings/account/EmailAddresses.js b/src/components/views/settings/account/EmailAddresses.js index e50039d0b6d..382d2ee93be 100644 --- a/src/components/views/settings/account/EmailAddresses.js +++ b/src/components/views/settings/account/EmailAddresses.js @@ -197,7 +197,7 @@ export default class EmailAddresses extends React.Component { if (err.errcode === 'M_THREEPID_AUTH_FAILED') { Modal.createTrackedDialog("Email hasn't been verified yet", "", ErrorDialog, { title: _t("Your email address hasn't been verified yet"), - description: _t("Click the link in the email you received to verify, " + + description: _t("Click the link in the email you received to verify " + "and then click continue again."), }); } else { diff --git a/src/components/views/settings/discovery/EmailAddresses.js b/src/components/views/settings/discovery/EmailAddresses.js index b83701cbed2..cc3d2d0dad1 100644 --- a/src/components/views/settings/discovery/EmailAddresses.js +++ b/src/components/views/settings/discovery/EmailAddresses.js @@ -175,7 +175,7 @@ export class EmailAddress extends React.Component { if (err.errcode === 'M_THREEPID_AUTH_FAILED') { Modal.createTrackedDialog("E-mail hasn't been verified yet", "", ErrorDialog, { title: _t("Your email address hasn't been verified yet"), - description: _t("Click the link in the email you received to verify, " + + description: _t("Click the link in the email you received to verify " + "and then click continue again."), }); } else { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ba0fbf628e5..31a26e6dcb0 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -741,7 +741,7 @@ "Unable to revoke sharing for email address": "Unable to revoke sharing for email address", "Unable to share email address": "Unable to share email address", "Your email address hasn't been verified yet": "Your email address hasn't been verified yet", - "Click the link in the email you received to verify, and then click continue again.": "Click the link in the email you received to verify, and then click continue again.", + "Click the link in the email you received to verify and then click continue again.": "Click the link in the email you received to verify and then click continue again.", "Unable to verify email address.": "Unable to verify email address.", "Verify the link in your inbox": "Verify the link in your inbox", "Complete": "Complete",