大作业-修改了主页

This commit is contained in:
2024-06-12 00:02:55 +08:00
parent b59880f301
commit e48e752b91
20 changed files with 415 additions and 190 deletions

View File

@@ -0,0 +1,35 @@
from flask import flash, redirect, url_for
from pymysql.cursors import Cursor
def verify_user(cursor:Cursor, id:str, password:str) -> str:
# 检查已有用户
sql = """
SELECT COUNT(*) FROM passengers \
WHERE ID = %s;
"""
try:
cursor.execute(sql, (id,))
id_exist = cursor.fetchall()[0][0]
except Exception as e:
flash("数据库异常,查询失败")
print(e)
return redirect(url_for('signup'))
if (id_exist == 0):
return "NO_USER"
# 检查密码
sql = """
SELECT `Password` FROM passengers \
WHERE ID = %s;
"""
try:
cursor.execute(sql, (id,))
record_password = cursor.fetchall()[0][0]
except Exception as e:
flash("数据库异常,查询失败")
print(e)
return redirect(url_for('modify'))
if (record_password != password):
return "WRONG_PASSWORD"
return "USER_VERIFIED"