refactor: login by email (loginId kept as internal identifier)

This commit is contained in:
pray4skylark
2026-06-08 15:48:22 +09:00
parent 4a0c3ed278
commit ca444a3b4f
10 changed files with 34 additions and 31 deletions
+10 -10
View File
@@ -9,7 +9,7 @@ import type { LoginRequest } from '@/types';
export default function LoginPage() {
const router = useRouter();
const login = useAuthStore((s) => s.login);
const [loginId, setLoginId] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [showPw, setShowPw] = useState(false);
const [loading, setLoading] = useState(false);
@@ -17,14 +17,14 @@ export default function LoginPage() {
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!loginId.trim() || !password.trim()) {
setError('아이디와 비밀번호를 입력해주세요.');
if (!email.trim() || !password.trim()) {
setError('이메일과 비밀번호를 입력해주세요.');
return;
}
setLoading(true);
setError('');
try {
await login({ loginId, password } as LoginRequest);
await login({ email, password } as LoginRequest);
router.push('/');
} catch (err: unknown) {
const msg = (err as { message?: string })?.message || '로그인에 실패했습니다.';
@@ -53,14 +53,14 @@ export default function LoginPage() {
)}
<div>
<label className="block text-sm font-medium text-text-main mb-1.5">아이디</label>
<label className="block text-sm font-medium text-text-main mb-1.5">이메일</label>
<input
type="text"
value={loginId}
onChange={(e) => setLoginId(e.target.value)}
placeholder="아이디를 입력하세요"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="이메일을 입력하세요"
className="w-full px-4 py-2.5 rounded-xl border border-border bg-white text-text-main text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-all"
autoComplete="username"
autoComplete="email"
/>
</div>