Merge pull request #2148 from matrix-org/dbkr/dont_say_email_optional_if_it_isnt
Correctly mark email as optional
This commit is contained in:
commit
4517eaba6f
3 changed files with 39 additions and 7 deletions
|
@ -93,6 +93,7 @@ module.exports = React.createClass({
|
||||||
doingUIAuth: Boolean(this.props.sessionId),
|
doingUIAuth: Boolean(this.props.sessionId),
|
||||||
hsUrl: this.props.customHsUrl,
|
hsUrl: this.props.customHsUrl,
|
||||||
isUrl: this.props.customIsUrl,
|
isUrl: this.props.customIsUrl,
|
||||||
|
flows: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -145,11 +146,27 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_replaceClient: function() {
|
_replaceClient: async function() {
|
||||||
this._matrixClient = Matrix.createClient({
|
this._matrixClient = Matrix.createClient({
|
||||||
baseUrl: this.state.hsUrl,
|
baseUrl: this.state.hsUrl,
|
||||||
idBaseUrl: this.state.isUrl,
|
idBaseUrl: this.state.isUrl,
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
await this._makeRegisterRequest({});
|
||||||
|
// This should never succeed since we specified an empty
|
||||||
|
// auth object.
|
||||||
|
console.log("Expecting 401 from register request but got success!");
|
||||||
|
} catch (e) {
|
||||||
|
if (e.httpStatus === 401) {
|
||||||
|
this.setState({
|
||||||
|
flows: e.data.flows,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
errorText: _t("Unable to query for supported registration methods"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onFormSubmit: function(formVals) {
|
onFormSubmit: function(formVals) {
|
||||||
|
@ -378,7 +395,7 @@ module.exports = React.createClass({
|
||||||
poll={true}
|
poll={true}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (this.state.busy || this.state.teamServerBusy) {
|
} else if (this.state.busy || this.state.teamServerBusy || !this.state.flows) {
|
||||||
registerBody = <Spinner />;
|
registerBody = <Spinner />;
|
||||||
} else {
|
} else {
|
||||||
let serverConfigSection;
|
let serverConfigSection;
|
||||||
|
@ -408,6 +425,7 @@ module.exports = React.createClass({
|
||||||
onError={this.onFormValidationFailed}
|
onError={this.onFormValidationFailed}
|
||||||
onRegisterClick={this.onFormSubmit}
|
onRegisterClick={this.onFormSubmit}
|
||||||
onTeamSelected={this.onTeamSelected}
|
onTeamSelected={this.onTeamSelected}
|
||||||
|
flows={this.state.flows}
|
||||||
/>
|
/>
|
||||||
{ serverConfigSection }
|
{ serverConfigSection }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
Copyright 2017 Vector Creations Ltd
|
Copyright 2017 Vector Creations Ltd
|
||||||
|
Copyright 2018 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -49,7 +50,7 @@ module.exports = React.createClass({
|
||||||
teamsConfig: PropTypes.shape({
|
teamsConfig: PropTypes.shape({
|
||||||
// Email address to request new teams
|
// Email address to request new teams
|
||||||
supportEmail: PropTypes.string,
|
supportEmail: PropTypes.string,
|
||||||
teams: PropTypes.arrayOf(React.PropTypes.shape({
|
teams: PropTypes.arrayOf(PropTypes.shape({
|
||||||
// The displayed name of the team
|
// The displayed name of the team
|
||||||
"name": PropTypes.string,
|
"name": PropTypes.string,
|
||||||
// The domain of team email addresses
|
// The domain of team email addresses
|
||||||
|
@ -60,6 +61,7 @@ module.exports = React.createClass({
|
||||||
minPasswordLength: PropTypes.number,
|
minPasswordLength: PropTypes.number,
|
||||||
onError: PropTypes.func,
|
onError: PropTypes.func,
|
||||||
onRegisterClick: PropTypes.func.isRequired, // onRegisterClick(Object) => ?Promise
|
onRegisterClick: PropTypes.func.isRequired, // onRegisterClick(Object) => ?Promise
|
||||||
|
flows: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -273,12 +275,18 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_authStepIsRequired(step) {
|
||||||
|
// A step is required if no flow exists which does not include that step
|
||||||
|
// (Notwithstanding setups like either email or msisdn being required)
|
||||||
|
return !this.props.flows.some((flow) => {
|
||||||
|
return !flow.stages.includes(step);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
const theme = SettingsStore.getValue("theme");
|
const emailPlaceholder = this._authStepIsRequired('m.login.email.identity') ? _t("Email address") : _t("Email address (optional)");
|
||||||
// FIXME: remove hardcoded Status team tweaks at some point
|
|
||||||
const emailPlaceholder = theme === 'status' ? _t("Email address") : _t("Email address (optional)");
|
|
||||||
|
|
||||||
const emailSection = (
|
const emailSection = (
|
||||||
<div>
|
<div>
|
||||||
|
@ -315,6 +323,7 @@ module.exports = React.createClass({
|
||||||
const CountryDropdown = sdk.getComponent('views.login.CountryDropdown');
|
const CountryDropdown = sdk.getComponent('views.login.CountryDropdown');
|
||||||
let phoneSection;
|
let phoneSection;
|
||||||
if (!SdkConfig.get().disable_3pid_login) {
|
if (!SdkConfig.get().disable_3pid_login) {
|
||||||
|
const phonePlaceholder = this._authStepIsRequired('m.login.msisdn') ? _t("Mobile phone number") : _t("Mobile phone number (optional)");
|
||||||
phoneSection = (
|
phoneSection = (
|
||||||
<div className="mx_Login_phoneSection">
|
<div className="mx_Login_phoneSection">
|
||||||
<CountryDropdown ref="phone_country" onOptionChange={this._onPhoneCountryChange}
|
<CountryDropdown ref="phone_country" onOptionChange={this._onPhoneCountryChange}
|
||||||
|
@ -324,7 +333,7 @@ module.exports = React.createClass({
|
||||||
showPrefix={true}
|
showPrefix={true}
|
||||||
/>
|
/>
|
||||||
<input type="text" ref="phoneNumber"
|
<input type="text" ref="phoneNumber"
|
||||||
placeholder={_t("Mobile phone number (optional)")}
|
placeholder={phonePlaceholder}
|
||||||
defaultValue={this.props.defaultPhoneNumber}
|
defaultValue={this.props.defaultPhoneNumber}
|
||||||
className={this._classForField(
|
className={this._classForField(
|
||||||
FIELD_PHONE_NUMBER,
|
FIELD_PHONE_NUMBER,
|
||||||
|
|
|
@ -37,6 +37,11 @@ function doInputEmail(inputEmail, onTeamSelected) {
|
||||||
<RegistrationForm
|
<RegistrationForm
|
||||||
teamsConfig={TEAM_CONFIG}
|
teamsConfig={TEAM_CONFIG}
|
||||||
onTeamSelected={onTeamSelected}
|
onTeamSelected={onTeamSelected}
|
||||||
|
flows={[
|
||||||
|
{
|
||||||
|
stages: ['m.login.dummy'],
|
||||||
|
},
|
||||||
|
]}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue