Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix registration after clicking email link #2630

Merged
merged 3 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions src/components/structures/auth/Registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ module.exports = React.createClass({

getInitialState: function() {
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) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a note that these can come in from email verification, as a reminder for the future.

// or if custom URLs aren't allowed, skip them
!customURLsAllowed
) {
initialPhase = PHASE_REGISTRATION;
}

return {
busy: false,
Expand All @@ -87,7 +98,7 @@ module.exports = React.createClass({
hsUrl: this.props.customHsUrl,
isUrl: this.props.customIsUrl,
// Phase of the overall registration dialog.
phase: customURLsAllowed ? PHASE_SERVER_DETAILS : PHASE_REGISTRATION,
phase: initialPhase,
flows: null,
};
},
Expand All @@ -111,7 +122,7 @@ module.exports = React.createClass({
});
},

onServerTypeChange(type) {
onServerTypeChange(type, initial) {
this.setState({
serverType: type,
});
Expand All @@ -137,9 +148,15 @@ module.exports = React.createClass({
hsUrl: this.props.defaultHsUrl,
isUrl: this.props.defaultIsUrl,
});
this.setState({
phase: PHASE_SERVER_DETAILS,
});
// if this is the initial value from the control and we're
// 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;
}
},
Expand Down Expand Up @@ -372,9 +389,12 @@ module.exports = React.createClass({
// 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.
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>
<ServerTypeSelector
defaultHsUrl={this.props.defaultHsUrl}
defaultHsUrl={this.props.customHsUrl || this.props.defaultHsUrl}
onChange={this.onServerTypeChange}
/>
</div>;
Expand Down
6 changes: 5 additions & 1 deletion src/components/views/auth/ServerTypeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ export default class ServerTypeSelector extends React.PureComponent {
selected: type,
};
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);
}
}

Expand Down