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);
|
||||
},
|
||||
|
||||
componentWillReceiveProps: async function(newProps) {
|
||||
componentWillReceiveProps: function(newProps) {
|
||||
if (newProps.serverConfig.hsUrl === this.props.serverConfig.hsUrl &&
|
||||
newProps.serverConfig.isUrl === this.props.serverConfig.isUrl) return;
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ module.exports = React.createClass({
|
|||
|
||||
onPasswordLogin: function(username, phoneCountry, phoneNumber, password) {
|
||||
// Prevent people from submitting their password when something isn't right.
|
||||
if (this.isBusy() || !this.state.canTryLogin) return;
|
||||
if (this.isBusy()) return;
|
||||
|
||||
this.setState({
|
||||
busy: true,
|
||||
|
@ -156,6 +156,7 @@ module.exports = React.createClass({
|
|||
this._loginLogic.loginViaPassword(
|
||||
username, phoneCountry, phoneNumber, password,
|
||||
).then((data) => {
|
||||
this.setState({serverIsAlive: true}); // it must be, we logged in.
|
||||
this.props.onLoggedIn(data);
|
||||
}, (error) => {
|
||||
if (this._unmounted) {
|
||||
|
@ -240,7 +241,7 @@ module.exports = React.createClass({
|
|||
username: username,
|
||||
busy: doWellknownLookup, // unset later by the result of onServerConfigChange
|
||||
errorText: null,
|
||||
canTryLogin: this.state.serverIsAlive,
|
||||
canTryLogin: true,
|
||||
});
|
||||
if (doWellknownLookup) {
|
||||
const serverName = username.split(':').slice(1).join(':');
|
||||
|
@ -259,7 +260,7 @@ module.exports = React.createClass({
|
|||
let discoveryState = {};
|
||||
if (AutoDiscoveryUtils.isLivelinessError(e)) {
|
||||
errorText = this.state.errorText;
|
||||
discoveryState = this._stateForDiscoveryError(e);
|
||||
discoveryState = AutoDiscoveryUtils.authComponentStateForError(e);
|
||||
}
|
||||
|
||||
this.setState({
|
||||
|
@ -291,7 +292,7 @@ module.exports = React.createClass({
|
|||
} else {
|
||||
this.setState({
|
||||
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) {
|
||||
hsUrl = hsUrl || this.props.serverConfig.hsUrl;
|
||||
isUrl = isUrl || this.props.serverConfig.isUrl;
|
||||
|
@ -349,12 +343,11 @@ module.exports = React.createClass({
|
|||
// Do a quick liveliness check on the URLs
|
||||
try {
|
||||
await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, isUrl);
|
||||
this.setState({serverIsAlive: true, errorText: "", canTryLogin: true});
|
||||
this.setState({serverIsAlive: true, errorText: ""});
|
||||
} catch (e) {
|
||||
const discoveryState = this._stateForDiscoveryError(e);
|
||||
this.setState({
|
||||
busy: false,
|
||||
...discoveryState,
|
||||
...AutoDiscoveryUtils.authComponentStateForError(e),
|
||||
});
|
||||
return; // Server is dead - do not continue.
|
||||
}
|
||||
|
@ -529,7 +522,7 @@ module.exports = React.createClass({
|
|||
onForgotPasswordClick={this.props.onForgotPasswordClick}
|
||||
loginIncorrect={this.state.loginIncorrect}
|
||||
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.
|
||||
}
|
||||
|
||||
// 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'];
|
||||
let preferredIdentityUrl = "https://vector.im"; // We already know this is an IS, so don't validate it.
|
||||
if (isResult && isResult.state === AutoDiscovery.SUCCESS) {
|
||||
preferredIdentityUrl = isResult["base_url"];
|
||||
} else if (isResult && isResult.state !== AutoDiscovery.PROMPT) {
|
||||
|
|
Loading…
Reference in a new issue