From ec9e7f5855093a0bdb71c2e093c1a14c68eab97a Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 24 Sep 2019 15:02:30 +0100 Subject: [PATCH] Remove id_server for MSISDN registration For HSes that no longer need it, remove the id_server param when verifying MSISDNs at registration. Fixes https://github.com/vector-im/riot-web/issues/10941 --- .../auth/InteractiveAuthEntryComponents.js | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/components/views/auth/InteractiveAuthEntryComponents.js b/src/components/views/auth/InteractiveAuthEntryComponents.js index d2eb21df23..af41d07720 100644 --- a/src/components/views/auth/InteractiveAuthEntryComponents.js +++ b/src/components/views/auth/InteractiveAuthEntryComponents.js @@ -453,45 +453,45 @@ export const MsisdnAuthEntry = createReactClass({ }); }, - _onFormSubmit: function(e) { + _onFormSubmit: async function(e) { e.preventDefault(); if (this.state.token == '') return; - this.setState({ - errorText: null, - }); + this.setState({ + errorText: null, + }); - this.props.matrixClient.submitMsisdnToken( - this._sid, this.props.clientSecret, this.state.token, - ).then((result) => { + try { + const result = await this.props.matrixClient.submitMsisdnToken( + this._sid, this.props.clientSecret, this.state.token, + ); if (result.success) { - const idServerParsedUrl = url.parse( - this.props.matrixClient.getIdentityServerUrl(), - ); + const creds = { + sid: this._sid, + client_secret: this.props.clientSecret, + }; + if (await this.props.matrixClient.doesServerRequireIdServerParam()) { + const idServerParsedUrl = url.parse( + this.props.matrixClient.getIdentityServerUrl(), + ); + creds.id_server = idServerParsedUrl.host; + } 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, - }, + threepid_creds: creds, + threepidCreds: creds, }); } else { this.setState({ errorText: _t("Token incorrect"), }); } - }).catch((e) => { + } catch (e) { this.props.fail(e); console.log("Failed to submit msisdn token"); - }).done(); + } }, render: function() {