feat: 修改密码+密码可见切换+所有项目tab
- 新增 POST /api/auth/change-password 修改密码接口 - 修改密码弹窗,三次密码输入均带眼睛切换可见 - 业务模块新增「所有项目」tab,展示全部项目 - 版本号 v1.0.0.15
This commit is contained in:
@@ -92,6 +92,30 @@ def auth_logout():
|
||||
return jsonify({"ok": True})
|
||||
|
||||
|
||||
@bp.route("/api/auth/change-password", methods=["POST"])
|
||||
@login_required
|
||||
def auth_change_password():
|
||||
data = request.get_json(force=True) or {}
|
||||
old_password = data.get("old_password", "")
|
||||
new_password = data.get("new_password", "")
|
||||
if not old_password or not new_password:
|
||||
return jsonify({"error": "旧密码和新密码不能为空"}), 400
|
||||
if len(new_password) < 6:
|
||||
return jsonify({"error": "新密码至少需要6位"}), 400
|
||||
user_id = session.get("user_id")
|
||||
conn = db()
|
||||
try:
|
||||
user = one(conn, "SELECT * FROM users WHERE id=?", (user_id,))
|
||||
if not user or not check_password_hash(user["password_hash"], old_password):
|
||||
return jsonify({"error": "旧密码错误"}), 401
|
||||
new_hash = generate_password_hash(new_password)
|
||||
_exec(conn, "UPDATE users SET password_hash=? WHERE id=?", (new_hash, user_id))
|
||||
conn.commit()
|
||||
return jsonify({"ok": True})
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
@bp.route("/api/auth/me")
|
||||
def auth_me():
|
||||
if "user_id" not in session:
|
||||
|
||||
Reference in New Issue
Block a user