Skip to content
Snippets Groups Projects
Commit 066b91db authored by Hugo Brua's avatar Hugo Brua
Browse files

:pencil: stock user email in cookie

parent 39e26f74
4 merge requests!6Finalisation du panier,!5Stock,!3Develop,!2:sparkless: add auth persistance
This commit is part of merge request !3. Comments created here will be created in the context of that merge request.
......@@ -21,7 +21,7 @@ function AuthProvider({ children }: { children: React.ReactNode }) {
let signin = (newUser: string, callback: VoidFunction) => {
return fakeAuthProvider.signin(() => {
setUser(newUser);
bake_cookie('isLogin', true);
bake_cookie('user', newUser);
callback();
});
};
......@@ -29,7 +29,7 @@ function AuthProvider({ children }: { children: React.ReactNode }) {
let signout = (callback: VoidFunction) => {
return fakeAuthProvider.signout(() => {
setUser(null);
delete_cookie('isLogin');
delete_cookie('user');
callback();
});
};
......
......@@ -10,7 +10,7 @@ function RequireAuth({ children }: { children: JSX.Element }) {
let auth = useAuth();
let location = useLocation();
if (read_cookie('isLogin') != true && !auth.user) {
if (read_cookie('user') == false && !auth.user) {
// Redirect them to the /login page, but save the current location they were
// trying to go to when they were redirected. This allows us to send them
// along to that page after they login, which is a nicer user experience
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment