From dbe5c2cb452dc858d6cce9c08a61c0be4aeded41 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Aug 2019 18:11:24 +0100 Subject: [PATCH] Allow password reset without an ID Server If the server advertises that it supports doing so Requires matrix-org/matrix-js-sdk#1018 Requires matrix-org/matrix-js-sdk#1019 Fixes vector-im/riot-web#10572 --- src/PasswordReset.js | 6 +++++- src/components/structures/auth/ForgotPassword.js | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/PasswordReset.js b/src/PasswordReset.js index df51e4d846..0dd5802962 100644 --- a/src/PasswordReset.js +++ b/src/PasswordReset.js @@ -36,7 +36,11 @@ class PasswordReset { idBaseUrl: identityUrl, }); this.clientSecret = this.client.generateClientSecret(); - this.identityServerDomain = identityUrl.split("://")[1]; + this.identityServerDomain = identityUrl ? identityUrl.split("://")[1] : null; + } + + doesServerRequireIdServerParam() { + return this.client.doesServerRequireIdServerParam(); } /** diff --git a/src/components/structures/auth/ForgotPassword.js b/src/components/structures/auth/ForgotPassword.js index 0c1a8ec33d..6d80f66d64 100644 --- a/src/components/structures/auth/ForgotPassword.js +++ b/src/components/structures/auth/ForgotPassword.js @@ -62,10 +62,12 @@ module.exports = React.createClass({ serverIsAlive: true, serverErrorIsFatal: false, serverDeadError: "", + serverRequiresIdServer: null, }; }, componentWillMount: function() { + this.reset = null; this._checkServerLiveliness(this.props.serverConfig); }, @@ -83,7 +85,14 @@ module.exports = React.createClass({ serverConfig.hsUrl, serverConfig.isUrl, ); - this.setState({serverIsAlive: true}); + + const pwReset = new PasswordReset(serverConfig.hsUrl, serverConfig.isUrl); + const serverRequiresIdServer = await pwReset.doesServerRequireIdServerParam(); + + this.setState({ + serverIsAlive: true, + serverRequiresIdServer, + }); } catch (e) { this.setState(AutoDiscoveryUtils.authComponentStateForError(e, "forgot_password")); } @@ -256,7 +265,7 @@ module.exports = React.createClass({ ; } - if (!this.props.serverConfig.isUrl) { + if (!this.props.serverConfig.isUrl && this.state.serverRequiresIdServer) { return

{yourMatrixAccountText}