refactor: 인증 페이지를 React Hook Form 컴포넌트로 마이그레이션
- signup/page.tsx: SignupForm 컴포넌트 사용 - login/page.tsx: LoginForm 컴포넌트 사용 - reset-password/page.tsx: ResetPasswordForm 컴포넌트 사용 - auth/callback/route.ts: 불필요한 주석 제거
This commit is contained in:
@@ -1,13 +1,4 @@
|
||||
import Link from "next/link";
|
||||
import {
|
||||
login,
|
||||
signInWithGoogle,
|
||||
signInWithKakao,
|
||||
} from "@/features/auth/actions";
|
||||
import FormMessage from "@/components/form-message";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
@@ -15,8 +6,7 @@ import {
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import LoginForm from "@/features/auth/components/login-form";
|
||||
|
||||
/**
|
||||
* [로그인 페이지 컴포넌트]
|
||||
@@ -85,148 +75,8 @@ export default async function LoginPage({
|
||||
</CardHeader>
|
||||
|
||||
{/* ========== 카드 콘텐츠 영역 (폼) ========== */}
|
||||
<CardContent className="space-y-6">
|
||||
{/* 로그인 폼 - formAction으로 서버 액션(login) 연결 */}
|
||||
<form className="space-y-5">
|
||||
{/* ========== 이메일 입력 필드 ========== */}
|
||||
<div className="space-y-2">
|
||||
{/* htmlFor와 Input의 id 연결로 접근성 향상 */}
|
||||
<Label htmlFor="email" className="text-sm font-medium">
|
||||
이메일
|
||||
</Label>
|
||||
{/* autoComplete="email": 브라우저 자동완성 기능 활성화 */}
|
||||
{/* required: HTML5 필수 입력 검증 */}
|
||||
<Input
|
||||
id="email"
|
||||
name="email"
|
||||
type="email"
|
||||
placeholder="your@email.com"
|
||||
autoComplete="email"
|
||||
required
|
||||
className="h-11 transition-all duration-200"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ========== 비밀번호 입력 필드 ========== */}
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="password" className="text-sm font-medium">
|
||||
비밀번호
|
||||
</Label>
|
||||
{/* pattern: 최소 8자, 대문자, 소문자, 숫자, 특수문자 각 1개 이상 */}
|
||||
{/* 참고: HTML pattern에서는 <, >, {, } 등 일부 특수문자 사용 시 브라우저 호환성 문제 발생 */}
|
||||
<Input
|
||||
id="password"
|
||||
name="password"
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
autoComplete="current-password"
|
||||
required
|
||||
minLength={8}
|
||||
pattern="^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*]).{8,}$"
|
||||
title="비밀번호는 최소 8자 이상, 대문자, 소문자, 숫자, 특수문자를 각각 1개 이상 포함해야 합니다."
|
||||
className="h-11 transition-all duration-200"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 로그인 유지 & 비밀번호 찾기 */}
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox id="remember" name="remember-me" />
|
||||
<Label
|
||||
htmlFor="remember"
|
||||
className="cursor-pointer text-sm font-normal leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
||||
>
|
||||
로그인 유지
|
||||
</Label>
|
||||
</div>
|
||||
{/* 비밀번호 찾기 링크 */}
|
||||
<Link
|
||||
href="/forgot-password"
|
||||
className="text-sm font-medium text-gray-700 hover:text-black dark:text-gray-300 dark:hover:text-white"
|
||||
>
|
||||
비밀번호 찾기
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* 로그인 버튼 */}
|
||||
<Button
|
||||
formAction={login}
|
||||
type="submit"
|
||||
className="h-11 w-full bg-gradient-to-r from-gray-900 to-black font-semibold shadow-lg transition-all duration-200 hover:from-black hover:to-gray-800 hover:shadow-xl dark:from-white dark:to-gray-100 dark:text-black dark:hover:from-gray-100 dark:hover:to-white"
|
||||
size="lg"
|
||||
>
|
||||
로그인
|
||||
</Button>
|
||||
|
||||
{/* 회원가입 링크 */}
|
||||
<p className="text-center text-sm text-gray-600 dark:text-gray-400">
|
||||
계정이 없으신가요?{" "}
|
||||
<Link
|
||||
href="/signup"
|
||||
className="font-semibold text-gray-900 transition-colors hover:text-black dark:text-gray-100 dark:hover:text-white"
|
||||
>
|
||||
회원가입 하기
|
||||
</Link>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
{/* 소셜 로그인 구분선 */}
|
||||
<div className="relative">
|
||||
<Separator className="my-6" />
|
||||
<span className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white px-3 text-xs font-medium text-gray-500 dark:bg-gray-900 dark:text-gray-400">
|
||||
또는 소셜 로그인
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* 소셜 로그인 버튼들 */}
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
{/* ========== Google 로그인 버튼 ========== */}
|
||||
<form action={signInWithGoogle}>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="outline"
|
||||
className="h-11 w-full border-gray-200 bg-white shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-750"
|
||||
>
|
||||
<svg className="mr-2 h-5 w-5" viewBox="0 0 24 24">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
||||
/>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
||||
/>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
||||
/>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
||||
/>
|
||||
</svg>
|
||||
Google
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
{/* ========== Kakao 로그인 버튼 ========== */}
|
||||
<form action={signInWithKakao}>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="outline"
|
||||
className="h-11 w-full border-none bg-[#FEE500] font-semibold text-[#3C1E1E] shadow-sm transition-all duration-200 hover:bg-[#FDD835] hover:shadow-md"
|
||||
>
|
||||
<svg
|
||||
className="mr-2 h-5 w-5"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9 9-4.03 9-9-4.03-9-9-9zm-1.5 14.5h-3v-9h3v9zm3 0h-3v-5h3v5zm0-6h-3v-3h3v3z" />
|
||||
</svg>
|
||||
Kakao
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
<CardContent>
|
||||
<LoginForm />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user