修复Bug-490.

Bug490-ChenQiuwei
陈秋伟 2022-12-04 22:52:45 +08:00
parent e74f1ff477
commit 1ddab74f04
1 changed files with 19 additions and 10 deletions

View File

@ -5,6 +5,10 @@ from Login import check_username_availability, verify_user, add_user, get_expiry
# 初始化蓝图 # 初始化蓝图
accountService = Blueprint("accountService", __name__) accountService = Blueprint("accountService", __name__)
# 确认密码和输入密码是否一致
def verify_passverified(password,password2):
if(password==password2):
return True
### Sign-up, login, logout ### ### Sign-up, login, logout ###
@accountService.route("/signup", methods=['GET', 'POST']) @accountService.route("/signup", methods=['GET', 'POST'])
@ -20,6 +24,7 @@ def signup():
# POST方法需判断是否注册成功再根据结果返回不同的内容 # POST方法需判断是否注册成功再根据结果返回不同的内容
username = escape(request.form['username']) username = escape(request.form['username'])
password = escape(request.form['password']) password = escape(request.form['password'])
password2 = escape(request.form['password2'])
#! 添加如下代码为了过滤注册时的非法字符 #! 添加如下代码为了过滤注册时的非法字符
warn = WarningMessage(username) warn = WarningMessage(username)
@ -35,6 +40,8 @@ def signup():
else: # 添加账户信息 else: # 添加账户信息
add_user(username, password) add_user(username, password)
verified = verify_user(username, password) verified = verify_user(username, password)
verified_2 = verify_passverified(password, password2)
if verified_2: # 确认密码与输入密码一致后
if verified: if verified:
# 写入session # 写入session
session['logged_in'] = True session['logged_in'] = True
@ -46,6 +53,8 @@ def signup():
<p><a href="/%s">开始使用</a> <a href="/">返回首页</a><p/>' % (username, username, username) <p><a href="/%s">开始使用</a> <a href="/">返回首页</a><p/>' % (username, username, username)
else: else:
return '用户名密码验证失败。' return '用户名密码验证失败。'
else:
return '确认密码与输入密码不一致!'
@accountService.route("/login", methods=['GET', 'POST']) @accountService.route("/login", methods=['GET', 'POST'])