Skip to content

Commit c424f8a

Browse files
committed
Update page.tsx
1 parent e3bba4a commit c424f8a

File tree

1 file changed

+8
-7
lines changed
  • apps/snow-leopard/app/(auth)/login

1 file changed

+8
-7
lines changed

apps/snow-leopard/app/(auth)/login/page.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import Link from 'next/link';
4-
import { useRouter, useSearchParams } from 'next/navigation';
4+
import { useRouter } from 'next/navigation';
55
import { useState } from 'react';
66
import { authClient } from '@/lib/auth-client';
77
import { toast } from '@/components/toast';
@@ -10,8 +10,6 @@ import { SubmitButton } from '@/components/submit-button';
1010

1111
export 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);

0 commit comments

Comments
 (0)