Fixes: error handling on login page #13
Some checks failed
Build DeguApp backend / build (pull_request) Failing after 2m11s
Some checks failed
Build DeguApp backend / build (pull_request) Failing after 2m11s
This commit is contained in:
parent
7eb548e138
commit
d40af87c46
@ -90,7 +90,7 @@ export function AuthProvider({ children }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (resUser.status != 200) {
|
if (resUser.status != 200) {
|
||||||
throw Error("user does not have user data");
|
throw Error("Username or password is incorrect!");
|
||||||
}
|
}
|
||||||
|
|
||||||
const userData = await resUser.json();
|
const userData = await resUser.json();
|
||||||
@ -104,7 +104,7 @@ export function AuthProvider({ children }) {
|
|||||||
await storageUtil.setItem(TOKEN_KEY, loginData.data.jwt);
|
await storageUtil.setItem(TOKEN_KEY, loginData.data.jwt);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to log in", err);
|
console.error("Failed to log in", err);
|
||||||
return { error: true, msg: err.res };
|
return { error: true, msg: err };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,12 @@ function LoginPage() {
|
|||||||
}
|
}
|
||||||
}, [authState.authenticated]);
|
}, [authState.authenticated]);
|
||||||
|
|
||||||
function login() {
|
async function login() {
|
||||||
onLogin(email, pass);
|
const res = await onLogin(email, pass);
|
||||||
|
if (res !== undefined && res.error === true) {
|
||||||
|
alert(res.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user