注册回滚强制录入密码
This commit is contained in:
@@ -155,19 +155,12 @@ async def register(req: RegisterRequest, db: AsyncSession = Depends(get_db)):
|
||||
detail="该手机号已注册",
|
||||
)
|
||||
|
||||
existing_username = await db.execute(select(User).where(User.username == req.phone).limit(1))
|
||||
if existing_username.scalar_one_or_none():
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="该手机号已注册",
|
||||
)
|
||||
|
||||
user = User(
|
||||
id=generate_id(),
|
||||
username=req.phone,
|
||||
phone=req.phone,
|
||||
hashed_password=None,
|
||||
password_set_at=None,
|
||||
hashed_password=hash_password(req.password),
|
||||
password_set_at=datetime.now(),
|
||||
credits=100,
|
||||
is_admin=False,
|
||||
user_type="frontend",
|
||||
|
||||
Reference in New Issue
Block a user