Login: add general error message, when credentials are wrong

This commit is contained in:
knoxfighter 2021-01-19 04:57:47 +01:00
parent ec1fb466dc
commit 26e62e0f20

View File

@ -14,10 +14,14 @@ const Login = ({handleLogin}) => {
const location = useLocation();
const onSubmit = async data => {
const loginAttempt = await user.login(data)
if (loginAttempt?.username) {
await handleLogin(loginAttempt);
history.push('/');
try {
const loginAttempt = await user.login(data)
if (loginAttempt?.username) {
await handleLogin(loginAttempt);
history.push('/');
}
} catch (e) {
window.flash("Login failed. Username or Password wrong.", "red");
}
};