This commit is contained in:
pro.boooooo
2024-04-01 12:55:40 +02:00
parent 61a3513ef4
commit 7402661aaa
22 changed files with 175 additions and 73 deletions

View File

@@ -33,22 +33,25 @@ export const AuthenticationProvider = ({ children }) => {
};
const login = async (email, password) => {
loginApi(email, password)
.then((user) => {
setAuthState({ user });
redirect();
})
.catch(() => {
console.error("ici ca catch fort");
setAuthState({ user: undefined });
});
try {
const user = await loginApi(email, password);
setAuthState({ user });
redirect();
} catch (error) {
console.error("Erreur lors de la connexion :", error);
setAuthState({ user: undefined });
}
};
const register = async (username, password, confirmation) => {
registerApi(username, password, confirmation).then((user) => {
try {
const user = await registerApi(username, password, confirmation);
setAuthState({ user });
redirect();
});
} catch (error) {
console.error("Erreur lors de l'inscription :", error);
setAuthState({ user: undefined });
}
};
const logout = () => {