Handle login errors
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user