Redirect to login without token and not on a public route

This commit is contained in:
Rotimi Best
2023-07-07 18:31:22 +01:00
parent 450d37034f
commit 5fcb517c58
4 changed files with 24 additions and 2 deletions
+12
View File
@@ -32,6 +32,7 @@
isQuizPage,
} from '../utils/functions/app';
import showAppsSideBar from '../utils/functions/showAppsSideBar';
import isPublicRoute from '../utils/functions/routes/isPublicRoute';
import { user, profile } from '../utils/store/user';
import { getSupabase } from '../utils/functions/supabase';
import { isMobile } from '../utils/store/useMobile';
@@ -194,6 +195,17 @@
handleResize();
if (
!localStorage.getItem('supabase.auth.token') &&
!isPublicRoute($page.path)
) {
console.log(
'No auth token and is not a public route, redirect to login',
path
);
return goto('/login');
}
const { data: authListener } = supabase.auth.onAuthStateChange(
(event, session) => {
// Log key events