From 10377b42e9177a3a66475d9fb469237fce609cb5 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 12 Jun 2019 17:42:09 +0100 Subject: [PATCH 1/2] Fix registration with email + non-default HS We were ignoring the hs/is from the query parameters so after clicking the link, the new client tried to use the wrong server. Broken by https://github.com/matrix-org/matrix-react-sdk/pull/2941 Fixes https://github.com/vector-im/riot-web/issues/9659 --- src/components/structures/MatrixChat.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 56cf81b985..2af2c6dccb 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -219,6 +219,18 @@ export default React.createClass({ return {serverConfig: props}; }, + getRegisterServerProperties() { + const props = this.getServerProperties(); + if (this.state.register_hs_url) { + props.hsUrl = this.state.register_hs_url; + } + if (this.state.register_is_url) { + props.isUrl = this.state.register_is_url; + } + + return {serverConfig: props}; + }, + componentWillMount: function() { SdkConfig.put(this.props.config); @@ -1871,7 +1883,7 @@ export default React.createClass({ onLoggedIn={this.onRegistered} onLoginClick={this.onLoginClick} onServerConfigChange={this.onServerConfigChange} - {...this.getServerProperties()} + {...this.getRegisterServerProperties()} /> ); } From 1139f68de800620d70848aeb4dfbe7f165d16431 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 12 Jun 2019 18:11:58 +0100 Subject: [PATCH 2/2] Pass in object of the right type --- src/components/structures/MatrixChat.js | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 2af2c6dccb..15a244b50e 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -51,7 +51,8 @@ import SettingsStore, {SettingLevel} from "../../settings/SettingsStore"; import { startAnyRegistrationFlow } from "../../Registration.js"; import { messageForSyncError } from '../../utils/ErrorUtils'; import ResizeNotifier from "../../utils/ResizeNotifier"; -import {ValidatedServerConfig} from "../../utils/AutoDiscoveryUtils"; +import { ValidatedServerConfig } from "../../utils/AutoDiscoveryUtils"; +import AutoDiscoveryUtils from "../../utils/AutoDiscoveryUtils"; // Disable warnings for now: we use deprecated bluebird functions // and need to migrate, but they spam the console with warnings. @@ -219,18 +220,6 @@ export default React.createClass({ return {serverConfig: props}; }, - getRegisterServerProperties() { - const props = this.getServerProperties(); - if (this.state.register_hs_url) { - props.hsUrl = this.state.register_hs_url; - } - if (this.state.register_is_url) { - props.isUrl = this.state.register_is_url; - } - - return {serverConfig: props}; - }, - componentWillMount: function() { SdkConfig.put(this.props.config); @@ -688,7 +677,7 @@ export default React.createClass({ }); }, - _startRegistration: function(params) { + _startRegistration: async function(params) { const newState = { view: VIEWS.REGISTER, }; @@ -701,10 +690,12 @@ export default React.createClass({ params.is_url && params.sid ) { + newState.serverConfig = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls( + params.hs_url, params.is_url, + ); + newState.register_client_secret = params.client_secret; newState.register_session_id = params.session_id; - newState.register_hs_url = params.hs_url; - newState.register_is_url = params.is_url; newState.register_id_sid = params.sid; } @@ -1883,7 +1874,7 @@ export default React.createClass({ onLoggedIn={this.onRegistered} onLoginClick={this.onLoginClick} onServerConfigChange={this.onServerConfigChange} - {...this.getRegisterServerProperties()} + {...this.getServerProperties()} /> ); }