Fix HS/IS URL reset when switching to Registration

pull/21833/head
lukebarnard 2018-02-07 15:51:03 +00:00
parent cf4ae681f4
commit 45ad46b468
3 changed files with 37 additions and 11 deletions

View File

@ -618,18 +618,26 @@ export default React.createClass({
}, },
_startRegistration: function(params) { _startRegistration: function(params) {
this.setStateForNewView({ const newState = {
view: VIEWS.REGISTER, view: VIEWS.REGISTER,
// these params may be undefined, but if they are, };
// unset them from our state: we don't want to
// resume a previous registration session if the // Only honour params if they are all present, otherwise we reset
// user just clicked 'register' // HS and IS URLs when switching to registration.
register_client_secret: params.client_secret, if (params.client_secret &&
register_session_id: params.session_id, params.session_id &&
register_hs_url: params.hs_url, params.hs_url &&
register_is_url: params.is_url, params.is_url &&
register_id_sid: params.sid, params.sid
}); ) {
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;
}
this.setStateForNewView(newState);
this.notifyNewScreen('register'); this.notifyNewScreen('register');
}, },
@ -1501,6 +1509,17 @@ export default React.createClass({
} }
}, },
onServerConfigChange(config) {
const newState = {};
if (config.hsUrl) {
newState.register_hs_url = config.hsUrl;
}
if (config.isUrl) {
newState.register_is_url = config.isUrl;
}
this.setState(newState);
},
_makeRegistrationUrl: function(params) { _makeRegistrationUrl: function(params) {
if (this.props.startingFragmentQueryParams.referrer) { if (this.props.startingFragmentQueryParams.referrer) {
params.referrer = this.props.startingFragmentQueryParams.referrer; params.referrer = this.props.startingFragmentQueryParams.referrer;
@ -1589,6 +1608,7 @@ export default React.createClass({
onLoginClick={this.onLoginClick} onLoginClick={this.onLoginClick}
onRegisterClick={this.onRegisterClick} onRegisterClick={this.onRegisterClick}
onCancelClick={MatrixClientPeg.get() ? this.onReturnToAppClick : null} onCancelClick={MatrixClientPeg.get() ? this.onReturnToAppClick : null}
onServerConfigChange={this.onServerConfigChange}
/> />
); );
} }
@ -1623,6 +1643,7 @@ export default React.createClass({
onForgotPasswordClick={this.onForgotPasswordClick} onForgotPasswordClick={this.onForgotPasswordClick}
enableGuest={this.props.enableGuest} enableGuest={this.props.enableGuest}
onCancelClick={MatrixClientPeg.get() ? this.onReturnToAppClick : null} onCancelClick={MatrixClientPeg.get() ? this.onReturnToAppClick : null}
onServerConfigChange={this.onServerConfigChange}
/> />
); );
} }

View File

@ -58,6 +58,7 @@ module.exports = React.createClass({
// login shouldn't care how password recovery is done. // login shouldn't care how password recovery is done.
onForgotPasswordClick: PropTypes.func, onForgotPasswordClick: PropTypes.func,
onCancelClick: PropTypes.func, onCancelClick: PropTypes.func,
onServerConfigChange: PropTypes.func.isRequired,
}, },
getInitialState: function() { getInitialState: function() {
@ -218,6 +219,8 @@ module.exports = React.createClass({
if (config.isUrl !== undefined) { if (config.isUrl !== undefined) {
newState.enteredIdentityServerUrl = config.isUrl; newState.enteredIdentityServerUrl = config.isUrl;
} }
this.props.onServerConfigChange(config);
this.setState(newState, function() { this.setState(newState, function() {
self._initLoginLogic(config.hsUrl || null, config.isUrl); self._initLoginLogic(config.hsUrl || null, config.isUrl);
}); });

View File

@ -61,6 +61,7 @@ module.exports = React.createClass({
// registration shouldn't know or care how login is done. // registration shouldn't know or care how login is done.
onLoginClick: PropTypes.func.isRequired, onLoginClick: PropTypes.func.isRequired,
onCancelClick: PropTypes.func, onCancelClick: PropTypes.func,
onServerConfigChange: PropTypes.func.isRequired,
}, },
getInitialState: function() { getInitialState: function() {
@ -131,6 +132,7 @@ module.exports = React.createClass({
if (config.isUrl !== undefined) { if (config.isUrl !== undefined) {
newState.isUrl = config.isUrl; newState.isUrl = config.isUrl;
} }
this.props.onServerConfigChange(config);
this.setState(newState, function() { this.setState(newState, function() {
this._replaceClient(); this._replaceClient();
}); });