Merge pull request #3318 from matrix-org/dbkr/allow_register_email_no_is
Allow registering with email if no ID Server
This commit is contained in:
commit
2a626c3f7c
3 changed files with 23 additions and 8 deletions
|
@ -98,6 +98,9 @@ module.exports = React.createClass({
|
||||||
// component without it.
|
// component without it.
|
||||||
matrixClient: null,
|
matrixClient: null,
|
||||||
|
|
||||||
|
// whether the HS requires an ID server to register with a threepid
|
||||||
|
serverRequiresIdServer: null,
|
||||||
|
|
||||||
// The user ID we've just registered
|
// The user ID we've just registered
|
||||||
registeredUsername: null,
|
registeredUsername: null,
|
||||||
|
|
||||||
|
@ -204,13 +207,23 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
const {hsUrl, isUrl} = serverConfig;
|
const {hsUrl, isUrl} = serverConfig;
|
||||||
this.setState({
|
const cli = Matrix.createClient({
|
||||||
matrixClient: Matrix.createClient({
|
baseUrl: hsUrl,
|
||||||
baseUrl: hsUrl,
|
idBaseUrl: isUrl,
|
||||||
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: cli,
|
||||||
|
serverRequiresIdServer,
|
||||||
|
busy: false,
|
||||||
});
|
});
|
||||||
this.setState({busy: false});
|
|
||||||
try {
|
try {
|
||||||
await this._makeRegisterRequest({});
|
await this._makeRegisterRequest({});
|
||||||
// This should never succeed since we specified an empty
|
// This should never succeed since we specified an empty
|
||||||
|
@ -550,6 +563,7 @@ module.exports = React.createClass({
|
||||||
flows={this.state.flows}
|
flows={this.state.flows}
|
||||||
serverConfig={this.props.serverConfig}
|
serverConfig={this.props.serverConfig}
|
||||||
canSubmit={!this.state.serverErrorIsFatal}
|
canSubmit={!this.state.serverErrorIsFatal}
|
||||||
|
serverRequiresIdServer={this.state.serverRequiresIdServer}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -55,6 +55,7 @@ module.exports = React.createClass({
|
||||||
flows: PropTypes.arrayOf(PropTypes.object).isRequired,
|
flows: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
serverConfig: PropTypes.instanceOf(ValidatedServerConfig).isRequired,
|
serverConfig: PropTypes.instanceOf(ValidatedServerConfig).isRequired,
|
||||||
canSubmit: PropTypes.bool,
|
canSubmit: PropTypes.bool,
|
||||||
|
serverRequiresIdServer: PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -437,7 +438,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
_showEmail() {
|
_showEmail() {
|
||||||
const haveIs = Boolean(this.props.serverConfig.isUrl);
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -69,7 +69,7 @@ describe('Registration', function() {
|
||||||
|
|
||||||
const root = render();
|
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({
|
root.setState({
|
||||||
flows: [],
|
flows: [],
|
||||||
matrixClient: {},
|
matrixClient: {},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue