fix: 将密码最小长度调整为 11 位
This commit is contained in:
parent
cf6cc1d21a
commit
8c0bce45a4
@ -158,8 +158,8 @@ def validate_production_security() -> None:
|
|||||||
or JWT_SECRET.startswith("replace-") or len(JWT_SECRET) < 32):
|
or JWT_SECRET.startswith("replace-") or len(JWT_SECRET) < 32):
|
||||||
errors.append("JWT_SECRET 必须设置为至少 32 位的随机字符串")
|
errors.append("JWT_SECRET 必须设置为至少 32 位的随机字符串")
|
||||||
if (ADMIN_PASSWORD == "admin123" or ADMIN_PASSWORD.startswith("change-")
|
if (ADMIN_PASSWORD == "admin123" or ADMIN_PASSWORD.startswith("change-")
|
||||||
or len(ADMIN_PASSWORD) < 12):
|
or len(ADMIN_PASSWORD) < 11):
|
||||||
errors.append("ADMIN_PASSWORD 必须设置为至少 12 位的强密码")
|
errors.append("ADMIN_PASSWORD 必须设置为至少 11 位的强密码")
|
||||||
if not CORS_ALLOWED_ORIGINS or "*" in CORS_ALLOWED_ORIGINS:
|
if not CORS_ALLOWED_ORIGINS or "*" in CORS_ALLOWED_ORIGINS:
|
||||||
errors.append("CORS_ALLOWED_ORIGINS 必须设置为实际 HTTPS 前端域名,且不能为 *")
|
errors.append("CORS_ALLOWED_ORIGINS 必须设置为实际 HTTPS 前端域名,且不能为 *")
|
||||||
if not os.getenv("TRUSTED_HOSTS") or "*" in TRUSTED_HOSTS:
|
if not os.getenv("TRUSTED_HOSTS") or "*" in TRUSTED_HOSTS:
|
||||||
|
|||||||
@ -35,8 +35,8 @@ async def create_user(data: dict, user: dict = Depends(get_current_user), db: Se
|
|||||||
|
|
||||||
if not username or not password:
|
if not username or not password:
|
||||||
raise HTTPException(status_code=400, detail="用户名和密码不能为空")
|
raise HTTPException(status_code=400, detail="用户名和密码不能为空")
|
||||||
if len(password) < 12:
|
if len(password) < 11:
|
||||||
raise HTTPException(status_code=400, detail="密码至少 12 位")
|
raise HTTPException(status_code=400, detail="密码至少 11 位")
|
||||||
if db.query(User).filter(User.username == username).first():
|
if db.query(User).filter(User.username == username).first():
|
||||||
raise HTTPException(status_code=400, detail="用户名已存在")
|
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="用户不存在")
|
raise HTTPException(status_code=404, detail="用户不存在")
|
||||||
|
|
||||||
new_password = data.get("password", "").strip()
|
new_password = data.get("password", "").strip()
|
||||||
if not new_password or len(new_password) < 12:
|
if not new_password or len(new_password) < 11:
|
||||||
raise HTTPException(status_code=400, detail="密码至少 12 位")
|
raise HTTPException(status_code=400, detail="密码至少 11 位")
|
||||||
|
|
||||||
target.password_hash = hash_password(new_password)
|
target.password_hash = hash_password(new_password)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|||||||
@ -325,7 +325,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>密码 *</label>
|
<label>密码 *</label>
|
||||||
<input v-model="userForm.password" type="password" placeholder="至少 12 位">
|
<input v-model="userForm.password" type="password" placeholder="至少 11 位">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="checkbox-label">
|
<label class="checkbox-label">
|
||||||
@ -349,7 +349,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>新密码</label>
|
<label>新密码</label>
|
||||||
<input v-model="newPassword" type="password" placeholder="至少 12 位">
|
<input v-model="newPassword" type="password" placeholder="至少 11 位">
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 20px; display: flex; gap: 12px; justify-content: flex-end;">
|
<div style="margin-top: 20px; display: flex; gap: 12px; justify-content: flex-end;">
|
||||||
<button class="action-btn" style="padding: 8px 16px;" @click="showPasswordModal = false">取消</button>
|
<button class="action-btn" style="padding: 8px 16px;" @click="showPasswordModal = false">取消</button>
|
||||||
@ -650,8 +650,8 @@ const createUser = async () => {
|
|||||||
alert('请填写用户名和密码')
|
alert('请填写用户名和密码')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (userForm.value.password.length < 12) {
|
if (userForm.value.password.length < 11) {
|
||||||
alert('密码至少 12 位')
|
alert('密码至少 11 位')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -678,8 +678,8 @@ const openPasswordModal = (u) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const changePassword = async () => {
|
const changePassword = async () => {
|
||||||
if (!newPassword.value || newPassword.value.length < 12) {
|
if (!newPassword.value || newPassword.value.length < 11) {
|
||||||
alert('密码至少 12 位')
|
alert('密码至少 11 位')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user