Skip to content

Commit e9ed898

Browse files
added back nav useeffect to login
1 parent 667e6ee commit e9ed898

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Frontend/src/components/login.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { supabase } from "../database/superbase";
2-
import { useState } from "react";
2+
import { useEffect, useState } from "react";
33
import { useNavigate } from "react-router";
44
import { useTheme } from "../Contexts/ThemeProvider";
55
import { AlertCircle, Sun, Moon, Code } from "lucide-react";
@@ -32,6 +32,16 @@ function Login() {
3232
const [error, setError] = useState<string | null>(null);
3333
const [loading, setLoading] = useState(false);
3434

35+
// Redirect if session exists
36+
useEffect(() => {
37+
const checkSession = async () => {
38+
const {
39+
data: { session },
40+
} = await supabase.auth.getSession();
41+
if (session) navigate("/dashboard");
42+
};
43+
checkSession();
44+
}, [navigate]);
3545

3646
const signInWithGoogle = async () => {
3747
setError(null);

0 commit comments

Comments
 (0)