Skip to content
Snippets Groups Projects

:sparkless: add auth persistance

Merged BRUA HUGO requested to merge persistance into develop
Viewing commit 6826a526
Show latest version
2 files
+ 8
3
Preferences
Compare changes
Files
2
+ 1
2
@@ -4,13 +4,12 @@ import {
} from "react-router-dom";
import { useAuth } from "./useAuth";
import { read_cookie } from 'sfcookies';
function RequireAuth({ children }: { children: JSX.Element }) {
let auth = useAuth();
let location = useLocation();
if (read_cookie('user').length === 0 && !auth.user) {
if (!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