Handle login errors

This commit is contained in:
T'JAMPENS QUENTIN p2406187
2025-12-10 15:35:12 +01:00
parent 562a570dda
commit 95a167c663
3 changed files with 25 additions and 15 deletions
+3 -3
View File
@@ -19,12 +19,12 @@ export function AuthProvider({ children }) {
const login = async (email, password) => {
const res = await loginFunction(email, password);
if (!res || res.status !== 200) throw new Error("Login error");
const u = await getUser();
setUser(u);
const u = res.status === 200 ? await getUser() : null;
if (u) setUser(u);
return res;
};
const logout = async () => {
await logoutFunction();
setUser(null);