From 1ddab74f04b266c89aa2b230c0da6c0c1be4b1c7 Mon Sep 17 00:00:00 2001 From: 2658626578 <2658626578@qq.com> Date: Sun, 4 Dec 2022 22:52:45 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug-490.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/account_service.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/app/account_service.py b/app/account_service.py index dc854a3..77ed3f5 100644 --- a/app/account_service.py +++ b/app/account_service.py @@ -5,6 +5,10 @@ from Login import check_username_availability, verify_user, add_user, get_expiry # 初始化蓝图 accountService = Blueprint("accountService", __name__) +# 确认密码和输入密码是否一致 +def verify_passverified(password,password2): + if(password==password2): + return True ### Sign-up, login, logout ### @accountService.route("/signup", methods=['GET', 'POST']) @@ -20,6 +24,7 @@ def signup(): # POST方法需判断是否注册成功,再根据结果返回不同的内容 username = escape(request.form['username']) password = escape(request.form['password']) + password2 = escape(request.form['password2']) #! 添加如下代码为了过滤注册时的非法字符 warn = WarningMessage(username) @@ -35,17 +40,21 @@ def signup(): else: # 添加账户信息 add_user(username, password) verified = verify_user(username, password) - if verified: - # 写入session - session['logged_in'] = True - session[username] = username - session['username'] = username - session['expiry_date'] = get_expiry_date(username) - session['articleID'] = None - return '
恭喜,你已成功注册, 你的用户名是 %s。
\ - ' % (username, username, username) + verified_2 = verify_passverified(password, password2) + if verified_2: # 确认密码与输入密码一致后 + if verified: + # 写入session + session['logged_in'] = True + session[username] = username + session['username'] = username + session['expiry_date'] = get_expiry_date(username) + session['articleID'] = None + return '恭喜,你已成功注册, 你的用户名是 %s。
\ +' % (username, username, username) + else: + return '用户名密码验证失败。' else: - return '用户名密码验证失败。' + return '确认密码与输入密码不一致!' @accountService.route("/login", methods=['GET', 'POST']) -- 2.17.1 From 270f6159b2146780af3fef1244f04faae96c17c9 Mon Sep 17 00:00:00 2001 From: 2658626578 <2658626578@qq.com> Date: Sat, 10 Dec 2022 09:41:22 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug-490?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/account_service.py | 26 +++++++++++++------------- requirements.txt | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/account_service.py b/app/account_service.py index 77ed3f5..4de84ee 100644 --- a/app/account_service.py +++ b/app/account_service.py @@ -32,29 +32,29 @@ def signup(): return str(warn) available = check_username_availability(username) + verified_2 = verify_passverified(password, password2) if not available: # 用户名不可用 flash('用户名 %s 已经被注册。' % (username)) return render_template('signup.html') elif len(password.strip()) < 4: # 密码过短 return '密码过于简单。' + elif not verified_2: + return '确认密码与输入密码不一致!' else: # 添加账户信息 add_user(username, password) verified = verify_user(username, password) - verified_2 = verify_passverified(password, password2) - if verified_2: # 确认密码与输入密码一致后 - if verified: - # 写入session - session['logged_in'] = True - session[username] = username - session['username'] = username - session['expiry_date'] = get_expiry_date(username) - session['articleID'] = None - return '恭喜,你已成功注册, 你的用户名是 %s。
\ + if verified: + # 写入session + session['logged_in'] = True + session[username] = username + session['username'] = username + session['expiry_date'] = get_expiry_date(username) + session['articleID'] = None + return '恭喜,你已成功注册, 你的用户名是 %s。
\ ' % (username, username, username) - else: - return '用户名密码验证失败。' else: - return '确认密码与输入密码不一致!' + return '用户名密码验证失败。' + @accountService.route("/login", methods=['GET', 'POST']) diff --git a/requirements.txt b/requirements.txt index 2746a3b..8552794 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -Flask==1.1.2 +Flask==2.1.0 selenium==3.141.0 PyYAML~=6.0 -- 2.17.1 From 1fd7155b7be95e5c602b35d4d4672ed53f5c97f9 Mon Sep 17 00:00:00 2001 From: 2658626578 <2658626578@qq.com> Date: Sat, 10 Dec 2022 09:44:21 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=85=B3=E4=BA=8E=E4=BF=AE=E5=A4=8DBug-490?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/account_service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/account_service.py b/app/account_service.py index 4de84ee..1717889 100644 --- a/app/account_service.py +++ b/app/account_service.py @@ -32,7 +32,8 @@ def signup(): return str(warn) available = check_username_availability(username) - verified_2 = verify_passverified(password, password2) + + verified_2 = verify_passverified(password, password2) # 比较“密码”与“确认密码” if not available: # 用户名不可用 flash('用户名 %s 已经被注册。' % (username)) return render_template('signup.html') -- 2.17.1 From 7d2266131d0a63c4ee3949c59c25f97cac0830f6 Mon Sep 17 00:00:00 2001 From: Hui Lan恭喜,你已成功注册, 你的用户名是 %s。
\ -' % (username, username, username) + ' % (username, username, username) else: return '用户名密码验证失败。' -- 2.17.1 From 792da57b5025b054cc746fec8926d9f4d18a01c0 Mon Sep 17 00:00:00 2001 From: Hui Lan