feat: show api error message when logging in fails
This commit is contained in:
@@ -38,9 +38,21 @@ function LoginForm() {
|
|||||||
const { token } = data;
|
const { token } = data;
|
||||||
authentication.updateToken(token);
|
authentication.updateToken(token);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
enqueueSnackbar(error?.message || formatMessage('loginForm.error'), {
|
const errors = error?.response?.data?.errors
|
||||||
variant: 'error',
|
? Object.values(error.response.data.errors)
|
||||||
});
|
: [];
|
||||||
|
|
||||||
|
if (errors.length) {
|
||||||
|
for (const [error] of errors) {
|
||||||
|
enqueueSnackbar(error, {
|
||||||
|
variant: 'error',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
enqueueSnackbar(error?.message || formatMessage('loginForm.error'), {
|
||||||
|
variant: 'error',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user