Handle login errors

This commit is contained in:
T'JAMPENS QUENTIN p2406187 committed 2025-12-10 15:35:12 +01:00
1 parent 562a570dda
commit 95a167c663
3 files changed
+25 -15

No files matched your search

+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);