refactor: login by email (loginId kept as internal identifier)
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ export default function AccountsPage() {
|
||||
const handleCreate = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!createForm.loginId.trim() || !createForm.name.trim() || !createForm.password.trim()) {
|
||||
setCreateError('로그인 ID, 이름, 비밀번호는 필수입니다.');
|
||||
setCreateError('사번, 이름, 비밀번호는 필수입니다.');
|
||||
return;
|
||||
}
|
||||
setIsSubmitting(true);
|
||||
@@ -350,7 +350,7 @@ export default function AccountsPage() {
|
||||
{/* Basic Info */}
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label className={labelClass}>로그인 ID *</label>
|
||||
<label className={labelClass}>사번 *</label>
|
||||
<input value={createForm.loginId} onChange={(e) => setCreateForm((f) => ({ ...f, loginId: e.target.value }))} className={fieldClass} placeholder="login_id" />
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user