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

Allow registering with email if no ID Server #3318

Merged
merged 5 commits into from
Aug 19, 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
24 changes: 19 additions & 5 deletions src/components/structures/auth/Registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ module.exports = React.createClass({
// component without it.
matrixClient: null,

// whether the HS requires an ID server to register with a threepid
serverRequiresIdServer: null,

// The user ID we've just registered
registeredUsername: null,

Expand Down Expand Up @@ -204,13 +207,23 @@ module.exports = React.createClass({
}

const {hsUrl, isUrl} = serverConfig;
const cli = Matrix.createClient({
baseUrl: hsUrl,
idBaseUrl: isUrl,
});

let serverRequiresIdServer = true;
try {
serverRequiresIdServer = await cli.doesServerRequireIdServerParam();
} catch (e) {
console.log("Unable to determine is server needs id_server param", e);
}

this.setState({
matrixClient: Matrix.createClient({
baseUrl: hsUrl,
idBaseUrl: isUrl,
}),
matrixClient: cli,
serverRequiresIdServer,
busy: false,
});
this.setState({busy: false});
try {
await this._makeRegisterRequest({});
// This should never succeed since we specified an empty
Expand Down Expand Up @@ -550,6 +563,7 @@ module.exports = React.createClass({
flows={this.state.flows}
serverConfig={this.props.serverConfig}
canSubmit={!this.state.serverErrorIsFatal}
serverRequiresIdServer={this.state.serverRequiresIdServer}
/>;
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/auth/RegistrationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = React.createClass({
flows: PropTypes.arrayOf(PropTypes.object).isRequired,
serverConfig: PropTypes.instanceOf(ValidatedServerConfig).isRequired,
canSubmit: PropTypes.bool,
serverRequiresIdServer: PropTypes.bool,
},

getDefaultProps: function() {
Expand Down Expand Up @@ -437,7 +438,7 @@ module.exports = React.createClass({

_showEmail() {
const haveIs = Boolean(this.props.serverConfig.isUrl);
if (!haveIs || !this._authStepIsUsed('m.login.email.identity')) {
if ((this.props.serverRequiresIdServer && !haveIs) || !this._authStepIsUsed('m.login.email.identity')) {
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion test/components/structures/auth/Registration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('Registration', function() {

const root = render();

// Set non-empty flow & matrixClient to get past the loading spinner
// Set non-empty flows & matrixClient to get past the loading spinner
Copy link
Member Author

Choose a reason for hiding this comment

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

unrelated but tiny comment fix

root.setState({
flows: [],
matrixClient: {},
Expand Down