Wire up 'create account' to the SSO button when SSO is used
For https://github.com/vector-im/riot-web/issues/12362
This commit is contained in:
parent
846170b371
commit
8234b4d656
1 changed files with 28 additions and 3 deletions
|
@ -120,8 +120,8 @@ export default createReactClass({
|
|||
'm.login.password': this._renderPasswordStep,
|
||||
|
||||
// CAS and SSO are the same thing, modulo the url we link to
|
||||
'm.login.cas': () => this._renderSsoStep(this._loginLogic.getSsoLoginUrl("cas")),
|
||||
'm.login.sso': () => this._renderSsoStep(this._loginLogic.getSsoLoginUrl("sso")),
|
||||
'm.login.cas': () => this._renderSsoStep(this._getSsoUrl('m.login.cas')),
|
||||
'm.login.sso': () => this._renderSsoStep(this._getSsoUrl('m.login.sso')),
|
||||
};
|
||||
|
||||
this._initLoginLogic();
|
||||
|
@ -150,6 +150,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});
|
||||
|
@ -344,6 +356,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,
|
||||
|
@ -654,7 +679,7 @@ export default createReactClass({
|
|||
{ serverDeadSection }
|
||||
{ this.renderServerComponent() }
|
||||
{ this.renderLoginComponentForStep() }
|
||||
<a className="mx_AuthBody_changeFlow" onClick={this.onRegisterClick} href="#">
|
||||
<a className="mx_AuthBody_changeFlow" onClick={this.onTryRegisterClick} href="#">
|
||||
{ _t('Create account') }
|
||||
</a>
|
||||
</AuthBody>
|
||||
|
|
Loading…
Reference in a new issue