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:
parent
2de215356b
commit
a155e7638d
3 changed files with 5 additions and 6 deletions
|
@ -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
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 = {
|
||||||
|
|
|
@ -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) => {
|
||||||
|
|
Loading…
Reference in a new issue