Skip to content

Commit a155e76

Browse files
authored
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)
1 parent 2de2153 commit a155e76

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

client/modules/User/actions.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ export function validateAndLoginUser(previousPath, formProps, dispatch) {
6464
browserHistory.push(previousPath);
6565
resolve();
6666
})
67-
.catch((response) => {
68-
reject({ password: response.data.message, _error: 'Login failed!' }); // eslint-disable-line
69-
});
67+
.catch(error =>
68+
reject({ password: error.response.data.message, _error: 'Login failed!' })); // eslint-disable-line
7069
});
7170
}
7271

client/modules/User/pages/LoginView.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ function mapDispatchToProps() {
8181

8282
LoginView.propTypes = {
8383
previousPath: PropTypes.string.isRequired,
84-
user: {
84+
user: PropTypes.shape({
8585
authenticated: PropTypes.bool
86-
}
86+
})
8787
};
8888

8989
LoginView.defaultProps = {

server/controllers/session.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function createSession(req, res, next) {
44
passport.authenticate('local', (err, user) => { // eslint-disable-line consistent-return
55
if (err) { return next(err); }
66
if (!user) {
7-
return res.status(401).send({ message: 'Invalid username or password.' });
7+
return res.status(401).json({ message: 'Invalid username or password.' });
88
}
99

1010
req.logIn(user, (innerErr) => {

0 commit comments

Comments
 (0)