fix: 将密码最小长度调整为 11 位
This commit is contained in:
@@ -35,8 +35,8 @@ async def create_user(data: dict, user: dict = Depends(get_current_user), db: Se
|
||||
|
||||
if not username or not password:
|
||||
raise HTTPException(status_code=400, detail="用户名和密码不能为空")
|
||||
if len(password) < 12:
|
||||
raise HTTPException(status_code=400, detail="密码至少 12 位")
|
||||
if len(password) < 11:
|
||||
raise HTTPException(status_code=400, detail="密码至少 11 位")
|
||||
if db.query(User).filter(User.username == username).first():
|
||||
raise HTTPException(status_code=400, detail="用户名已存在")
|
||||
|
||||
@@ -61,8 +61,8 @@ async def change_password(user_id: str, data: dict, user: dict = Depends(get_cur
|
||||
raise HTTPException(status_code=404, detail="用户不存在")
|
||||
|
||||
new_password = data.get("password", "").strip()
|
||||
if not new_password or len(new_password) < 12:
|
||||
raise HTTPException(status_code=400, detail="密码至少 12 位")
|
||||
if not new_password or len(new_password) < 11:
|
||||
raise HTTPException(status_code=400, detail="密码至少 11 位")
|
||||
|
||||
target.password_hash = hash_password(new_password)
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user