Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
fix: login form
Browse files Browse the repository at this point in the history
  • Loading branch information
jspark2000 committed Feb 27, 2024
1 parent 70817b7 commit fdb7fb4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frontend/src/app/(public)/login/_components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import { Input } from '@/components/ui/input'
import { LoginFormSchema } from '@/lib/forms'
import { zodResolver } from '@hookform/resolvers/zod'
import { signIn } from 'next-auth/react'
import { useRouter } from 'next/navigation'
import { useState } from 'react'
import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
import type { z } from 'zod'

export default function LoginForm() {
const [isFetching, setIsFetching] = useState(false)
const router = useRouter()

const form = useForm<z.infer<typeof LoginFormSchema>>({
resolver: zodResolver(LoginFormSchema),
Expand All @@ -34,12 +36,11 @@ export default function LoginForm() {
setIsFetching(true)
const res = await signIn('credentials', {
...data,
redirect: true,
callbackUrl: '/'
redirect: false
})

if (!res?.error) {
toast.success('로그인 되었습니다')
router.push('/')
} else {
toast.error('로그인 실패')
}
Expand Down

0 comments on commit fdb7fb4

Please sign in to comment.