Merge branch 'Bug490-ChenQiuwei' of http://121.4.94.30:3000/mrlan/EnglishPal into Bug490-ChenQiuwei

Bug490-ChenQiuwei
Hui Lan 2023-01-29 11:40:40 +08:00
commit 4a2770eb2f
2 changed files with 12 additions and 2 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)
@ -27,11 +32,15 @@ def signup():
return str(warn) return str(warn)
available = check_username_availability(username) available = check_username_availability(username)
verified_2 = verify_passverified(password, password2) # 比较“密码”与“确认密码”
if not available: # 用户名不可用 if not available: # 用户名不可用
flash('用户名 %s 已经被注册。' % (username)) flash('用户名 %s 已经被注册。' % (username))
return render_template('signup.html') return render_template('signup.html')
elif len(password.strip()) < 4: # 密码过短 elif len(password.strip()) < 4: # 密码过短
return '密码过于简单。' return '密码过于简单。'
elif not verified_2:
return '确认密码与输入密码不一致!'
else: # 添加账户信息 else: # 添加账户信息
add_user(username, password) add_user(username, password)
verified = verify_user(username, password) verified = verify_user(username, password)
@ -48,6 +57,7 @@ def signup():
return '用户名密码验证失败。' return '用户名密码验证失败。'
@accountService.route("/login", methods=['GET', 'POST']) @accountService.route("/login", methods=['GET', 'POST'])
def login(): def login():
''' '''

View File

@ -1,3 +1,3 @@
Flask==1.1.2 Flask==2.1.0
selenium==3.141.0 selenium==3.141.0
PyYAML~=6.0 PyYAML~=6.0