File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
apps/snow-leopard/app/(auth)/login Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 11'use client' ;
22
33import Link from 'next/link' ;
4- import { useRouter , useSearchParams } from 'next/navigation' ;
4+ import { useRouter } from 'next/navigation' ;
55import { useState } from 'react' ;
66import { authClient } from '@/lib/auth-client' ;
77import { toast } from '@/components/toast' ;
@@ -10,8 +10,6 @@ import { SubmitButton } from '@/components/submit-button';
1010
1111export default function LoginPage ( ) {
1212 const router = useRouter ( ) ;
13- const searchParams = useSearchParams ( ) ;
14- const redirectTo = searchParams . get ( 'redirect' ) || '/documents' ;
1513 const [ isLoading , setIsLoading ] = useState ( false ) ;
1614 const [ isSuccessful , setIsSuccessful ] = useState ( false ) ;
1715 const [ email , setEmail ] = useState ( '' ) ;
@@ -24,17 +22,20 @@ export default function LoginPage() {
2422 await authClient . signIn . email ( {
2523 email : currentEmail ,
2624 password,
27- callbackURL : redirectTo ,
25+ callbackURL : "/documents"
2826 } , {
2927 onRequest : ( ) => {
3028 setIsLoading ( true ) ;
3129 setIsSuccessful ( false ) ;
3230 } ,
33- onSuccess : ( ) => {
31+ onSuccess : ( ctx ) => {
3432 setIsLoading ( false ) ;
3533 setIsSuccessful ( true ) ;
36- toast ( { type : 'success' , description : 'Signed in successfully! Redirecting...' } ) ;
37- router . push ( redirectTo ) ;
34+ toast ( {
35+ type : 'success' ,
36+ description : 'Signed in successfully! Redirecting...'
37+ } ) ;
38+ router . refresh ( ) ;
3839 } ,
3940 onError : ( ctx ) => {
4041 setIsLoading ( false ) ;
You can’t perform that action at this time.
0 commit comments