re #1153: fix bug in which login form was in invalid state if user had entered username or password incorrectly on the first try (#1155)

This commit is contained in:
Cassie Tarakajian 2019-09-06 13:30:06 -04:00 committed by GitHub
parent 2de215356b
commit a155e7638d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 6 deletions

View file

@ -64,9 +64,8 @@ export function validateAndLoginUser(previousPath, formProps, dispatch) {
browserHistory.push(previousPath); browserHistory.push(previousPath);
resolve(); resolve();
}) })
.catch((response) => { .catch(error =>
reject({ password: response.data.message, _error: 'Login failed!' }); // eslint-disable-line reject({ password: error.response.data.message, _error: 'Login failed!' })); // eslint-disable-line
});
}); });
} }

View file

@ -81,9 +81,9 @@ function mapDispatchToProps() {
LoginView.propTypes = { LoginView.propTypes = {
previousPath: PropTypes.string.isRequired, previousPath: PropTypes.string.isRequired,
user: { user: PropTypes.shape({
authenticated: PropTypes.bool authenticated: PropTypes.bool
} })
}; };
LoginView.defaultProps = { LoginView.defaultProps = {

View file

@ -4,7 +4,7 @@ export function createSession(req, res, next) {
passport.authenticate('local', (err, user) => { // eslint-disable-line consistent-return passport.authenticate('local', (err, user) => { // eslint-disable-line consistent-return
if (err) { return next(err); } if (err) { return next(err); }
if (!user) { if (!user) {
return res.status(401).send({ message: 'Invalid username or password.' }); return res.status(401).json({ message: 'Invalid username or password.' });
} }
req.logIn(user, (innerErr) => { req.logIn(user, (innerErr) => {