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

Commit

Permalink
Merge pull request #3318 from matrix-org/dbkr/allow_register_email_no_is
Browse files Browse the repository at this point in the history
Allow registering with email if no ID Server
  • Loading branch information
dbkr authored Aug 19, 2019
2 parents cf1b7ab + a87fb7e commit 2a626c3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
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
root.setState({
flows: [],
matrixClient: {},
Expand Down

0 comments on commit 2a626c3

Please sign in to comment.