Files
auto-trade/app/reset-password/page.tsx
jihoon87.lee 151626b181 Feat: 소셜 로그인 추가 및 인증 페이지 UI 테마 정리
app/login/page.tsx
- Google/Kakao 소셜 로그인 버튼을 폼으로 연동하고 액션 호출 추가
- 로그인 페이지의 배경/버튼/텍스트 색상 등 UI 테마를 파스텔에서 그레이/다크톤으로 통일
- 소셜 버튼 마크업 및 스타일 정리

app/signup/page.tsx
- 회원가입 페이지 배경 및 버튼 색상을 그레이/다크톤으로 변경
- 아이콘 배경 그라디언트 및 링크 색상 업데이트

app/forgot-password/page.tsx
- 비밀번호 재설정 요청 페이지의 배경, 블러 효과 및 버튼 스타일을 그레이/다크톤으로 변경
- 아이콘 배경 및 링크 색상 업데이트

app/reset-password/page.tsx
- 비밀번호 재설정 페이지의 배경, 블러 효과 및 버튼 스타일을 그레이/다크톤으로 변경
- 아이콘 배경 업데이트

features/auth/actions.ts
- Google 및 Kakao OAuth 시작을 위한 공통 헬퍼(signInWithProvider) 추가
- signInWithGoogle 및 signInWithKakao 액션을 구현하여 OAuth 흐름을 시작하도록 추가
2026-02-03 15:44:55 +09:00

146 lines
6.5 KiB
TypeScript

import FormMessage from "@/components/form-message";
import { updatePassword } from "@/features/auth/actions";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { createClient } from "@/utils/supabase/server";
import { redirect } from "next/navigation";
/**
* [비밀번호 재설정 페이지]
*
* 이메일 링크를 통해 접근한 사용자만 새 비밀번호를 설정할 수 있습니다.
* Supabase recovery 세션 검증으로 직접 URL 접근 차단
*
* PKCE 플로우:
* 1. 사용자가 비밀번호 재설정 이메일의 링크 클릭
* 2. Supabase가 토큰 검증 후 이 페이지로 ?code=xxx 파라미터와 함께 리다이렉트
* 3. 이 페이지에서 code를 세션으로 교환
* 4. 유효한 세션이 있으면 비밀번호 재설정 폼 표시
*
* @param searchParams - URL 쿼리 파라미터 (code: PKCE 코드, message: 에러/성공 메시지)
*/
export default async function ResetPasswordPage({
searchParams,
}: {
searchParams: Promise<{ message?: string; code?: string }>;
}) {
const params = await searchParams;
const supabase = await createClient();
// 1. 이메일 링크에서 code 파라미터 확인
// Supabase는 이메일 링크를 통해 ?code=xxx 형태로 PKCE code를 전달합니다
if (params.code) {
// code를 세션으로 교환
const { error } = await supabase.auth.exchangeCodeForSession(params.code);
if (error) {
// code 교환 실패 (만료되었거나 유효하지 않음)
console.error("Password reset code exchange error:", error.message);
const message = encodeURIComponent(
"비밀번호 재설정 링크가 만료되었거나 유효하지 않습니다.",
);
redirect(`/login?message=${message}`);
}
// code 교환 성공 - code 없이 같은 페이지로 리다이렉트
// (URL을 깨끗하게 유지하고 세션 쿠키가 설정된 상태로 리로드)
redirect("/reset-password");
}
// 2. 세션 확인
const {
data: { user },
} = await supabase.auth.getUser();
// 3. 유효한 세션이 없으면 로그인 페이지로 리다이렉트
if (!user) {
const message = encodeURIComponent(
"비밀번호 재설정 링크가 만료되었거나 유효하지 않습니다.",
);
redirect(`/login?message=${message}`);
}
// URL에서 메시지 파라미터 추출
const { message } = params;
return (
<div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-gradient-to-br from-gray-50 via-white to-gray-100 px-4 py-12 dark:from-black dark:via-gray-950 dark:to-gray-900">
{/* ========== 배경 그라디언트 ========== */}
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,_var(--tw-gradient-stops))] from-gray-200/30 via-gray-100/15 to-transparent dark:from-gray-800/30 dark:via-gray-900/20" />
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_bottom_left,_var(--tw-gradient-stops))] from-gray-300/30 via-gray-200/15 to-transparent dark:from-gray-700/30 dark:via-gray-800/20" />
{/* ========== 애니메이션 블러 효과 ========== */}
<div className="absolute left-1/4 top-1/4 h-64 w-64 animate-pulse rounded-full bg-gray-300/20 blur-3xl dark:bg-gray-700/20" />
<div className="absolute bottom-1/4 right-1/4 h-64 w-64 animate-pulse rounded-full bg-gray-400/20 blur-3xl delay-700 dark:bg-gray-600/20" />
{/* ========== 메인 콘텐츠 ========== */}
<div className="relative z-10 w-full max-w-md animate-in fade-in slide-in-from-bottom-4 duration-700">
{/* 에러/성공 메시지 */}
{message && <FormMessage message={message} />}
{/* ========== 비밀번호 재설정 카드 ========== */}
<Card className="border-white/20 bg-white/70 shadow-2xl backdrop-blur-xl dark:border-white/10 dark:bg-gray-900/70">
<CardHeader className="space-y-3 text-center">
{/* 아이콘 */}
<div className="mx-auto mb-2 flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-gray-800 to-black shadow-lg dark:from-white dark:to-gray-200">
<span className="text-4xl">🔐</span>
</div>
{/* 페이지 제목 */}
<CardTitle className="text-3xl font-bold tracking-tight">
</CardTitle>
{/* 페이지 설명 */}
<CardDescription className="text-base">
.
</CardDescription>
</CardHeader>
{/* ========== 폼 영역 ========== */}
<CardContent className="space-y-6">
{/* 비밀번호 업데이트 폼 */}
<form className="space-y-5">
{/* ========== 새 비밀번호 입력 ========== */}
<div className="space-y-2">
<Label htmlFor="password" className="text-sm font-medium">
</Label>
<Input
id="password"
name="password"
type="password"
placeholder="••••••••"
autoComplete="new-password"
required
minLength={8}
pattern="^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*]).{8,}$"
title="비밀번호는 최소 8자 이상, 대문자, 소문자, 숫자, 특수문자를 각각 1개 이상 포함해야 합니다."
className="h-11 transition-all duration-200"
/>
<p className="text-xs text-gray-500 dark:text-gray-400">
8 , , , ,
</p>
</div>
{/* ========== 비밀번호 변경 버튼 ========== */}
<Button
formAction={updatePassword}
className="h-11 w-full bg-gradient-to-r from-gray-900 to-black font-semibold text-white shadow-lg transition-all 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"
>
</Button>
</form>
</CardContent>
</Card>
</div>
</div>
);
}