Merge pull request #2630 from matrix-org/dbkr/fix_register_email_link

Fix registration after clicking email link
pull/21833/head
David Baker 2019-02-13 19:25:15 +00:00 committed by GitHub
commit 0ad9d71935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 7 deletions

View File

@ -64,6 +64,17 @@ module.exports = React.createClass({
getInitialState: function() { getInitialState: function() {
const customURLsAllowed = !SdkConfig.get()['disable_custom_urls']; const customURLsAllowed = !SdkConfig.get()['disable_custom_urls'];
let initialPhase = PHASE_SERVER_DETAILS;
if (
// if we have these two, skip to the good bit
// (they could come in from the URL params in a
// registration email link)
(this.props.clientSecret && this.props.sessionId) ||
// or if custom URLs aren't allowed, skip them
!customURLsAllowed
) {
initialPhase = PHASE_REGISTRATION;
}
return { return {
busy: false, busy: false,
@ -87,7 +98,7 @@ module.exports = React.createClass({
hsUrl: this.props.customHsUrl, hsUrl: this.props.customHsUrl,
isUrl: this.props.customIsUrl, isUrl: this.props.customIsUrl,
// Phase of the overall registration dialog. // Phase of the overall registration dialog.
phase: customURLsAllowed ? PHASE_SERVER_DETAILS : PHASE_REGISTRATION, phase: initialPhase,
flows: null, flows: null,
}; };
}, },
@ -111,7 +122,7 @@ module.exports = React.createClass({
}); });
}, },
onServerTypeChange(type) { onServerTypeChange(type, initial) {
this.setState({ this.setState({
serverType: type, serverType: type,
}); });
@ -137,9 +148,15 @@ module.exports = React.createClass({
hsUrl: this.props.defaultHsUrl, hsUrl: this.props.defaultHsUrl,
isUrl: this.props.defaultIsUrl, isUrl: this.props.defaultIsUrl,
}); });
this.setState({ // if this is the initial value from the control and we're
phase: PHASE_SERVER_DETAILS, // already in the registration phase, don't go back to the
}); // server details phase (but do if it's actually a change resulting
// from user interaction).
if (!initial || !this.state.phase === PHASE_REGISTRATION) {
this.setState({
phase: PHASE_SERVER_DETAILS,
});
}
break; break;
} }
}, },
@ -372,9 +389,12 @@ module.exports = React.createClass({
// If we're on a different phase, we only show the server type selector, // If we're on a different phase, we only show the server type selector,
// which is always shown if we allow custom URLs at all. // which is always shown if we allow custom URLs at all.
if (PHASES_ENABLED && this.state.phase !== PHASE_SERVER_DETAILS) { if (PHASES_ENABLED && this.state.phase !== PHASE_SERVER_DETAILS) {
// if we've been given a custom HS URL we should actually pass that, so
// that the appropriate section is selected at the start to match the
// homeserver URL we're using
return <div> return <div>
<ServerTypeSelector <ServerTypeSelector
defaultHsUrl={this.props.defaultHsUrl} defaultHsUrl={this.props.customHsUrl || this.props.defaultHsUrl}
onChange={this.onServerTypeChange} onChange={this.onServerTypeChange}
/> />
</div>; </div>;

View File

@ -90,7 +90,11 @@ export default class ServerTypeSelector extends React.PureComponent {
selected: type, selected: type,
}; };
if (onChange) { if (onChange) {
onChange(type); // FIXME: Supply a second 'initial' param here to flag that this is
// initialising the value rather than from user interaction
// (which sometimes we'll want to ignore). Must be a better way
// to do this.
onChange(type, true);
} }
} }