Skip to content

Commit

Permalink
fix: login redirect to home
Browse files Browse the repository at this point in the history
  • Loading branch information
debendraoli committed Nov 25, 2024
1 parent bc13ef6 commit c836c22
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/(authentication)/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function Login({ callbackUrl }: { callbackUrl: string }) {
const login = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
setSubmitting(true)
setError('')
try {
const formData = new FormData(e.currentTarget)
const res = await signIn('credentials', {
Expand All @@ -46,8 +47,8 @@ export default function Login({ callbackUrl }: { callbackUrl: string }) {
setError('Login failed')
return
}
await new Promise((resolve) => setTimeout(resolve, 1000))
router.push('/')
await new Promise((resolve) => setTimeout(resolve, 5000))
router.replace(url || '/')
} catch (err) {
if (err instanceof Error) {
setError(err.message)
Expand Down

0 comments on commit c836c22

Please sign in to comment.