File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11import { supabase } from "../database/superbase" ;
2- import { useState } from "react" ;
2+ import { useEffect , useState } from "react" ;
33import { useNavigate } from "react-router" ;
44import { useTheme } from "../Contexts/ThemeProvider" ;
55import { 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 ) ;
You can’t perform that action at this time.
0 commit comments