Make sure password and re-entered password are the same during sign-up.

Bug490-ChenQiuwei
Hui Lan 2023-01-29 11:45:27 +08:00
parent 4a2770eb2f
commit 7d2266131d
2 changed files with 2 additions and 8 deletions

View File

@ -5,11 +5,6 @@ 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'])
def signup(): def signup():
@ -33,13 +28,12 @@ def signup():
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: elif password != password2:
return '确认密码与输入密码不一致!' return '确认密码与输入密码不一致!'
else: # 添加账户信息 else: # 添加账户信息
add_user(username, password) add_user(username, password)

View File

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