mirror of
https://github.com/zoriya/flood.git
synced 2026-05-25 08:23:26 +00:00
Fix error handling in login form
This commit is contained in:
@@ -9,18 +9,25 @@ const baseURI = ConfigStore.getBaseURI();
|
||||
let AuthActions = {
|
||||
authenticate: (credentials) => {
|
||||
return axios.post(`${baseURI}auth/authenticate`, credentials)
|
||||
.then((json = {}) => {
|
||||
return json.data;
|
||||
})
|
||||
.then((data) => {
|
||||
AppDispatcher.dispatchServerAction({
|
||||
type: ActionTypes.AUTH_LOGIN_SUCCESS,
|
||||
data
|
||||
});
|
||||
}, (error) => {
|
||||
let errorMessage;
|
||||
|
||||
if (error.response) {
|
||||
errorMessage = error.response.data.message;
|
||||
} else if (error.message) {
|
||||
errorMessage = error.message;
|
||||
} else {
|
||||
errorMessage = 'An unknown error occurred.';
|
||||
}
|
||||
|
||||
AppDispatcher.dispatchServerAction({
|
||||
type: ActionTypes.AUTH_LOGIN_ERROR,
|
||||
error: error.data.message
|
||||
error: errorMessage
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
+37
-37
File diff suppressed because one or more lines are too long
@@ -16,7 +16,7 @@ router.post('/authenticate', (req, res) => {
|
||||
username: req.body.username
|
||||
};
|
||||
|
||||
Users.comparePassword(credentials, function(isMatch, err) {
|
||||
Users.comparePassword(credentials, (isMatch, err) => {
|
||||
if (isMatch == null) {
|
||||
return res.status(401).json({message: 'You entered an incorrect username.'});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user