From becd7e9d7dc7817188bf29ae49c8e687ccdf5043 Mon Sep 17 00:00:00 2001 From: zhouyanfeng <1057045639@qq.com> Date: Tue, 23 May 2023 21:40:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E7=A0=81=E5=A4=8D=E6=9D=82=E5=BA=A6?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86=E6=BA=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=9A=84=20account=5Fservice.py=20=E6=96=87=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E4=BA=86=E5=AF=B9=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E4=B8=AD=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6=E5=92=8C=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E5=86=99=E5=AD=97=E6=AF=8D=E7=9A=84=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E8=A6=81=E6=B1=82=E6=A3=80=E6=9F=A5=EF=BC=8C=E5=B9=B6=E5=B0=86?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E7=9A=84=E6=9C=80=E4=BD=8E=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E9=99=90=E5=88=B6=E6=8F=90=E5=8D=87=E5=88=B0=208=20=E4=BD=8D?= =?UTF-8?q?=E4=BB=A5=E6=8F=90=E9=AB=98=E7=94=A8=E6=88=B7=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E7=9A=84=E5=AE=89=E5=85=A8=E6=80=A7=E3=80=82=20=E4=BD=86?= =?UTF-8?q?=E4=B8=8E=E8=AF=A5=E7=89=88=E6=9C=ACEnglishPal=E4=B8=ADjsonify?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E8=B5=B7=E5=86=B2=E7=AA=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/account_service.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/app/account_service.py b/app/account_service.py index a7ed0c4..e4ff95b 100644 --- a/app/account_service.py +++ b/app/account_service.py @@ -23,11 +23,39 @@ def signup(): #! 添加如下代码为了过滤注册时的非法字符 warn = WarningMessage(username) if str(warn) != 'OK': - return jsonify({'status': '3', 'warn': str(warn)}) + return str(warn) + # return jsonify({'status': '3', 'warn': str(warn)}) available = check_username_availability(username) if not available: # 用户名不可用 - return jsonify({'status': '0'}) + flash('用户名 %s 已经被注册。' %(username)) + return render_template('signup.html') + elif len(password.strip()) < 8: # 密码过短 + return '密码少于8位。' + # return jsonify({'status': '0'}) + + has_specialchar = False + specialchar_list = ['+', '-', '*', '/', '_', '&', '%', ','] + for c in password.strip(): + if c in specialchar_list: + has_specialchar = True + break + if not has_specialchar: + return '密码必须包含特殊字符' + + has_upper_letter = False + has_lower_letter = False + for c in password.strip(): + if c.isupper(): + has_upper_letter = True + elif c.islower(): + has_lower_letter = True + has_both_letter = has_upper_letter and has_lower_letter + if has_both_letter: + break + if not has_both_letter: + return '密码必须同时包含大写字母和小写字母' + else: # 添加账户信息 add_user(username, password) verified = verify_user(username, password)