fix(static): 禁用无认证的 /api/reset_password 接口

This commit is contained in:
qing committed 2026-08-03 14:26:06 +08:00
1 parent 5fbe3ed5e4
commit 4749e58eeb
1 file changed
+16 -15
+16 -15
View File
@@ -309,21 +309,22 @@ def api_hash():
return jsonify({"hash": h})
@app.route('/api/reset_password', methods=['POST'])
def api_reset_password():
from flask import request, jsonify
import sqlite3 as _sql
data = request.get_json(force=True)
email = data.get('email', '').strip()
new_hash = data.get('password_hash', '').strip()
if not email or not new_hash:
return jsonify({"success": False, "error": "missing params"}), 400
conn = _sql.connect(GATEWAY_DB)
conn.execute("UPDATE Users SET password_hash=? WHERE email=?", (new_hash, email))
conn.commit()
conn.close()
logs.info("static", "密码重置", extra={"email": email[:3] + "***"})
return jsonify({"success": True})
# DISABLED: P0 security issue - no authentication, allows arbitrary password reset
# @app.route('/api/reset_password', methods=['POST'])
# def api_reset_password():
# from flask import request, jsonify
# import sqlite3 as _sql
# data = request.get_json(force=True)
# email = data.get('email', '').strip()
# new_hash = data.get('password_hash', '').strip()
# if not email or not new_hash:
# return jsonify({"success": False, "error": "missing params"}), 400
# conn = _sql.connect(GATEWAY_DB)
# conn.execute("UPDATE Users SET password_hash=? WHERE email=?", (new_hash, email))
# conn.commit()
# conn.close()
# logs.info("static", "密码重置", extra={"email": email[:3] + "***"})
# return jsonify({"success": True})
@app.route('/api/check_user', methods=['POST'])