fix: 邮箱字段设置为唯一且必填,改善错误提示
后端改动: - User.email 设置为 unique=True,确保每个邮箱只能注册一次 - 这样 SendCodeView 能正确查找到已注册的邮箱 前端改动: - LoginView 增加详细的错误日志输出 - 捕获更多错误信息类型帮助调试 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
12697c5750
commit
b6d5a51c3d
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.2.20 on 2026-03-25 08:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0003_alter_user_phone'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='email',
|
||||
field=models.EmailField(max_length=254, unique=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -54,6 +54,7 @@ class User(AbstractUser):
|
|||
('admin', '公司管理员'),
|
||||
('seeker', '求职者'),
|
||||
]
|
||||
email = models.EmailField(unique=True) # 设置邮箱为唯一且必填
|
||||
role = models.CharField(max_length=20, choices=ROLE_CHOICES, default='seeker')
|
||||
phone = models.CharField(max_length=20)
|
||||
organization = models.ForeignKey(
|
||||
|
|
|
|||
|
|
@ -169,7 +169,12 @@ async function handleSendCode() {
|
|||
isLocked.value = false
|
||||
startCountdown()
|
||||
} catch (err) {
|
||||
ElMessage.error(err.response?.data?.error || err.response?.data?.email?.[0] || '发送失败,请检查邮箱是否正确')
|
||||
const errorMsg = err.response?.data?.error ||
|
||||
err.response?.data?.email?.[0] ||
|
||||
err.response?.data?.detail ||
|
||||
'发送失败,请检查邮箱是否正确'
|
||||
console.error('SendCode Error:', err.response?.data)
|
||||
ElMessage.error(errorMsg)
|
||||
} finally {
|
||||
sendingCode.value = false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue