From bcfe1fcac521378ecfaabd1273259eaca83f5f3b Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 3 Mar 2020 23:23:53 -0700 Subject: [PATCH] Wire up 'create account' to the SSO button when SSO is used For https://github.com/vector-im/riot-web/issues/12362 --- src/components/structures/auth/Login.js | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/components/structures/auth/Login.js b/src/components/structures/auth/Login.js index b918334d79..873c9e0c35 100644 --- a/src/components/structures/auth/Login.js +++ b/src/components/structures/auth/Login.js @@ -151,6 +151,18 @@ export default createReactClass({ return this.state.busy || this.props.busy; }, + _isSsoStep: function() { + return this._getCurrentFlowStep() === 'm.login.sso' || this._getCurrentFlowStep() === 'm.login.cas'; + }, + + _getSsoUrl: function(kind) { + if (kind === 'm.login.cas') { + return this._loginLogic.getSsoLoginUrl("cas") + } else { + return this._loginLogic.getSsoLoginUrl("sso"); + } + }, + onPasswordLogin: async function(username, phoneCountry, phoneNumber, password) { if (!this.state.serverIsAlive) { this.setState({busy: true}); @@ -339,6 +351,19 @@ export default createReactClass({ this.props.onRegisterClick(); }, + onTryRegisterClick: function(ev) { + if (this._isSsoStep()) { + // If we're showing SSO it means that registration is also probably disabled, + // so intercept the click and instead pretend the user clicked 'Sign in with SSO'. + ev.preventDefault(); + ev.stopPropagation(); + window.location = this._getSsoUrl(this._getCurrentFlowStep()); + } else { + // Don't intercept - just go through to the register page + this.onRegisterClick(ev); + } + }, + async onServerDetailsNextPhaseClick() { this.setState({ phase: PHASE_LOGIN, @@ -652,7 +677,7 @@ export default createReactClass({ { serverDeadSection } { this.renderServerComponent() } { this.renderLoginComponentForStep() } - + { _t('Create account') }