Allow the login form to be submitted, and clarify other things
This commit is contained in:
parent
c15ee1a829
commit
d59ad605a6
3 changed files with 14 additions and 17 deletions
|
@ -67,7 +67,7 @@ module.exports = React.createClass({
|
||||||
this._checkServerLiveliness(this.props.serverConfig);
|
this._checkServerLiveliness(this.props.serverConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps: async function(newProps) {
|
componentWillReceiveProps: function(newProps) {
|
||||||
if (newProps.serverConfig.hsUrl === this.props.serverConfig.hsUrl &&
|
if (newProps.serverConfig.hsUrl === this.props.serverConfig.hsUrl &&
|
||||||
newProps.serverConfig.isUrl === this.props.serverConfig.isUrl) return;
|
newProps.serverConfig.isUrl === this.props.serverConfig.isUrl) return;
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
onPasswordLogin: function(username, phoneCountry, phoneNumber, password) {
|
onPasswordLogin: function(username, phoneCountry, phoneNumber, password) {
|
||||||
// Prevent people from submitting their password when something isn't right.
|
// Prevent people from submitting their password when something isn't right.
|
||||||
if (this.isBusy() || !this.state.canTryLogin) return;
|
if (this.isBusy()) return;
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: true,
|
busy: true,
|
||||||
|
@ -156,6 +156,7 @@ module.exports = React.createClass({
|
||||||
this._loginLogic.loginViaPassword(
|
this._loginLogic.loginViaPassword(
|
||||||
username, phoneCountry, phoneNumber, password,
|
username, phoneCountry, phoneNumber, password,
|
||||||
).then((data) => {
|
).then((data) => {
|
||||||
|
this.setState({serverIsAlive: true}); // it must be, we logged in.
|
||||||
this.props.onLoggedIn(data);
|
this.props.onLoggedIn(data);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
if (this._unmounted) {
|
if (this._unmounted) {
|
||||||
|
@ -240,7 +241,7 @@ module.exports = React.createClass({
|
||||||
username: username,
|
username: username,
|
||||||
busy: doWellknownLookup, // unset later by the result of onServerConfigChange
|
busy: doWellknownLookup, // unset later by the result of onServerConfigChange
|
||||||
errorText: null,
|
errorText: null,
|
||||||
canTryLogin: this.state.serverIsAlive,
|
canTryLogin: true,
|
||||||
});
|
});
|
||||||
if (doWellknownLookup) {
|
if (doWellknownLookup) {
|
||||||
const serverName = username.split(':').slice(1).join(':');
|
const serverName = username.split(':').slice(1).join(':');
|
||||||
|
@ -259,7 +260,7 @@ module.exports = React.createClass({
|
||||||
let discoveryState = {};
|
let discoveryState = {};
|
||||||
if (AutoDiscoveryUtils.isLivelinessError(e)) {
|
if (AutoDiscoveryUtils.isLivelinessError(e)) {
|
||||||
errorText = this.state.errorText;
|
errorText = this.state.errorText;
|
||||||
discoveryState = this._stateForDiscoveryError(e);
|
discoveryState = AutoDiscoveryUtils.authComponentStateForError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -291,7 +292,7 @@ module.exports = React.createClass({
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
errorText: null,
|
errorText: null,
|
||||||
canTryLogin: this.state.serverIsAlive,
|
canTryLogin: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -316,13 +317,6 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_stateForDiscoveryError: function(err) {
|
|
||||||
return {
|
|
||||||
canTryLogin: false,
|
|
||||||
...AutoDiscoveryUtils.authComponentStateForError(err),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
_initLoginLogic: async function(hsUrl, isUrl) {
|
_initLoginLogic: async function(hsUrl, isUrl) {
|
||||||
hsUrl = hsUrl || this.props.serverConfig.hsUrl;
|
hsUrl = hsUrl || this.props.serverConfig.hsUrl;
|
||||||
isUrl = isUrl || this.props.serverConfig.isUrl;
|
isUrl = isUrl || this.props.serverConfig.isUrl;
|
||||||
|
@ -349,12 +343,11 @@ module.exports = React.createClass({
|
||||||
// Do a quick liveliness check on the URLs
|
// Do a quick liveliness check on the URLs
|
||||||
try {
|
try {
|
||||||
await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, isUrl);
|
await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, isUrl);
|
||||||
this.setState({serverIsAlive: true, errorText: "", canTryLogin: true});
|
this.setState({serverIsAlive: true, errorText: ""});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const discoveryState = this._stateForDiscoveryError(e);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: false,
|
busy: false,
|
||||||
...discoveryState,
|
...AutoDiscoveryUtils.authComponentStateForError(e),
|
||||||
});
|
});
|
||||||
return; // Server is dead - do not continue.
|
return; // Server is dead - do not continue.
|
||||||
}
|
}
|
||||||
|
@ -529,7 +522,7 @@ module.exports = React.createClass({
|
||||||
onForgotPasswordClick={this.props.onForgotPasswordClick}
|
onForgotPasswordClick={this.props.onForgotPasswordClick}
|
||||||
loginIncorrect={this.state.loginIncorrect}
|
loginIncorrect={this.state.loginIncorrect}
|
||||||
serverConfig={this.props.serverConfig}
|
serverConfig={this.props.serverConfig}
|
||||||
disableSubmit={this.isBusy() || !this.state.serverIsAlive}
|
disableSubmit={this.isBusy()}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -158,8 +158,12 @@ export default class AutoDiscoveryUtils {
|
||||||
} // else the error is not related to syntax - continue anyways.
|
} // else the error is not related to syntax - continue anyways.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: In the cases where we rely on this pre-populated "https://vector.im" (namely
|
||||||
|
// lack of identity server provided by the discovery method), we intentionally do not
|
||||||
|
// validate it. We already know the IS is an IS, and this helps some off-the-grid usage
|
||||||
|
// of Riot.
|
||||||
|
let preferredIdentityUrl = "https://vector.im";
|
||||||
const isResult = discoveryResult['m.identity_server'];
|
const isResult = discoveryResult['m.identity_server'];
|
||||||
let preferredIdentityUrl = "https://vector.im"; // We already know this is an IS, so don't validate it.
|
|
||||||
if (isResult && isResult.state === AutoDiscovery.SUCCESS) {
|
if (isResult && isResult.state === AutoDiscovery.SUCCESS) {
|
||||||
preferredIdentityUrl = isResult["base_url"];
|
preferredIdentityUrl = isResult["base_url"];
|
||||||
} else if (isResult && isResult.state !== AutoDiscovery.PROMPT) {
|
} else if (isResult && isResult.state !== AutoDiscovery.PROMPT) {
|
||||||
|
|
Loading…
Reference in a new issue