@@ -11,6 +11,8 @@ export const Route = createFileRoute("/app/auth")({
1111 component : Component ,
1212} ) ;
1313
14+ const redirectTo = import . meta. env . DEV ? "http://localhost:5173" : "https://api.hyprnote.com" ;
15+
1416function Component ( ) {
1517 const auth = useAuth ( ) ;
1618
@@ -41,13 +43,11 @@ function Component() {
4143
4244 const handleSignupEmail = useCallback ( async ( email : string , password : string ) => {
4345 if ( auth ?. supabase ) {
44- const redirectUrl = "hypr://auth/callback" ;
45-
4646 const { error } = await auth . supabase . auth . signUp ( {
4747 email,
4848 password,
4949 options : {
50- emailRedirectTo : redirectUrl ,
50+ emailRedirectTo : redirectTo ,
5151 } ,
5252 } ) ;
5353 console . error ( error ) ;
@@ -60,27 +60,34 @@ function Component() {
6060 provider : Provider ;
6161 } ) => {
6262 if ( auth ?. supabase ) {
63- const redirectUrl = "https://api.hyprnote.com/auth/callback" ;
6463 const { data, error } = await auth . supabase . auth . signInWithOAuth ( {
6564 provider,
6665 options : {
6766 skipBrowserRedirect : true ,
68- redirectTo : redirectUrl ,
67+ redirectTo,
6968 } ,
7069 } ) ;
71- if ( error ) {
70+
71+ if ( ! error && data . url ) {
72+ openUrl ( data . url ) ;
73+ } else {
7274 console . error ( error ) ;
7375 }
74- if ( data . url ) {
75- openUrl ( data . url ) ;
76+ }
77+ } , [ auth ?. supabase ] ) ;
78+
79+ const handleSignout = useCallback ( async ( ) => {
80+ if ( auth ?. supabase ) {
81+ const { error } = await auth . supabase . auth . signOut ( ) ;
82+ if ( error ) {
83+ console . error ( error ) ;
7684 }
7785 }
7886 } , [ auth ?. supabase ] ) ;
7987
8088 return (
8189 < div className = "flex flex-col h-full" >
8290 < Header />
83- < pre > session: { JSON . stringify ( auth ?. session , null , 2 ) } </ pre >
8491 < button
8592 className = "bg-blue-500 text-white px-4 py-2 rounded-md"
8693 onClick = { ( ) => handleSignupEmail ( "yujonglee.dev@gmail.com" , "fastreplwillwin1!" ) }
@@ -94,7 +101,16 @@ function Component() {
94101 signup with github
95102 </ button >
96103
104+ < button
105+ className = "bg-blue-500 text-white px-4 py-2 rounded-md"
106+ onClick = { ( ) => handleSignout ( ) }
107+ >
108+ signout
109+ </ button >
110+
97111 < ManualCodeProvider handleCode = { handleCode } />
112+
113+ < pre > session: { JSON . stringify ( auth ?. session , null , 2 ) } </ pre >
98114 </ div >
99115 ) ;
100116}
0 commit comments