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 #3218 from matrix-org/travis/check-when-dead
Browse files Browse the repository at this point in the history
Check for liveliness on submission when the server was previously dead
  • Loading branch information
turt2live authored Jul 15, 2019
2 parents d08cb70 + 2bc0e8e commit 2471f92
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/components/structures/auth/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,31 @@ module.exports = React.createClass({
return this.state.busy || this.props.busy;
},

onPasswordLogin: function(username, phoneCountry, phoneNumber, password) {
// Prevent people from submitting their password when something isn't right.
if (this.isBusy()) return;
onPasswordLogin: async function(username, phoneCountry, phoneNumber, password) {
if (!this.state.serverIsAlive) {
this.setState({busy: true});
// Do a quick liveliness check on the URLs
let aliveAgain = true;
try {
await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(
this.props.serverConfig.hsUrl,
this.props.serverConfig.isUrl,
);
this.setState({serverIsAlive: true, errorText: ""});
} catch (e) {
const componentState = AutoDiscoveryUtils.authComponentStateForError(e);
this.setState({
busy: false,
...componentState,
});
aliveAgain = !componentState.serverErrorIsFatal;
}

// Prevent people from submitting their password when something isn't right.
if (!aliveAgain) {
return;
}
}

this.setState({
busy: true,
Expand Down

0 comments on commit 2471f92

Please sign in to comment.