fix: polish authentication and responsive controls

This commit is contained in:
2026-08-05 11:43:43 +08:00
parent f6e36d737d
commit 1245a8ec1e
9 changed files with 102 additions and 29 deletions
+6 -1
View File
@@ -481,7 +481,10 @@ def login():
@bp.route("/register", methods=["GET", "POST"])
def register():
if request.method == "GET": return render_auth_template("register", captcha=refresh_captcha())
username, email, password = request.form.get("username", "").strip(), normal_email(request.form.get("email", "")), request.form.get("password", "")
username = request.form.get("username", "").strip()
email = normal_email(request.form.get("email", ""))
password = request.form.get("password", "")
confirmation = request.form.get("password_confirm", "")
if not captcha_is_valid():
return render_auth_error("register", "图形验证码错误", auth_error_field="captcha")
if not registration_allowed(): return render_auth_error("register", "当前未开放自助注册,请联系管理员。", 403)
@@ -491,6 +494,8 @@ def register():
return render_auth_error("register", "请输入有效的邮箱地址", auth_error_field="email")
if not valid_password(password):
return render_auth_error("register", PASSWORD_RULE_MESSAGE, auth_error_field="password")
if password != confirmation:
return render_auth_error("register", "两次密码输入不一致。", auth_error_field="password_confirm")
if User.query.filter((User.username == username) | (User.email == email)).first(): return render_auth_error("register", "显示名或邮箱已被使用")
user = User(username=username, email=email, is_admin=False, is_active_account=False)
user.set_password(password); db.session.add(user); db.session.commit()