Make sure error message never lies

Make sure we don't say 'login incorrect' unless the user is actually trying to log in
pull/21833/head
David Baker 2016-08-04 17:37:07 +01:00
parent bb3a7725db
commit 1f2b023885
1 changed files with 4 additions and 4 deletions

View File

@ -77,7 +77,7 @@ module.exports = React.createClass({displayName: 'Login',
this._loginLogic.loginViaPassword(username, password).then(function(data) { this._loginLogic.loginViaPassword(username, password).then(function(data) {
self.props.onLoggedIn(data); self.props.onLoggedIn(data);
}, function(error) { }, function(error) {
self._setStateFromError(error); self._setStateFromError(error, true);
}).finally(function() { }).finally(function() {
self.setState({ self.setState({
busy: false busy: false
@ -123,7 +123,7 @@ module.exports = React.createClass({displayName: 'Login',
// logins so let's skip that for now). // logins so let's skip that for now).
loginLogic.chooseFlow(0); loginLogic.chooseFlow(0);
}, function(err) { }, function(err) {
self._setStateFromError(err); self._setStateFromError(err, false);
}).finally(function() { }).finally(function() {
self.setState({ self.setState({
busy: false busy: false
@ -143,11 +143,11 @@ module.exports = React.createClass({displayName: 'Login',
return this._loginLogic ? this._loginLogic.getCurrentFlowStep() : null return this._loginLogic ? this._loginLogic.getCurrentFlowStep() : null
}, },
_setStateFromError: function(err) { _setStateFromError: function(err, isLoginAttempt) {
this.setState({ this.setState({
errorText: this._errorTextFromError(err), errorText: this._errorTextFromError(err),
// https://matrix.org/jira/browse/SYN-744 // https://matrix.org/jira/browse/SYN-744
loginIncorrect: err.httpStatus == 401 || err.httpStatus == 403 loginIncorrect: isLoginAttempt && (err.httpStatus == 401 || err.httpStatus == 403)
}); });
}, },