From 49b5780677e5669e812a53e024b8655b2697dd60 Mon Sep 17 00:00:00 2001 From: yangjian Date: Sun, 11 Apr 2021 19:45:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=B3=A8=E5=86=8C=E7=9A=84=E9=80=BB=E8=BE=91=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E4=B8=8E=E9=A1=B5=E9=9D=A2=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_admin/views.py | 9 ++++++--- template/app_admin/admin_user.html | 4 ++-- template/register.html | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app_admin/views.py b/app_admin/views.py index ef90e89..6dcd7ed 100644 --- a/app_admin/views.py +++ b/app_admin/views.py @@ -110,7 +110,7 @@ def register(request): elif username_exit.count() > 0: # 验证用户名 errormsg = _('用户名已被使用!') return render(request, 'register.html', locals()) - elif re.match('^[0-9a-z]+$',username) is False: + elif re.match('^[0-9a-z]+$',username) is None: errormsg = _('用户名只能为英文数字组合') return render(request, 'register.html', locals()) elif len(username) < 5: @@ -315,8 +315,11 @@ def admin_create_user(request): email = request.POST.get('email','') # 接收email参数 password = request.POST.get('password','') # 接收密码参数 user_type = request.POST.get('user_type',0) # 用户类型 0为普通用户,1位管理员 - if username != '' and password != '' and email != '' and \ - '@' in email and re.match(r'^[0-9a-z]',username) and len(username) >= 5 : + # 用户名只能为英文小写或数字且大于等于5位,密码大于等于6位 + if len(username) >= 5 and \ + len(password) >= 6 and \ + '@' in email and \ + re.match(r'^[0-9a-z]',username): # 不允许电子邮箱重复 if User.objects.filter(email = email).count() > 0: return JsonResponse({'status':False,'data':_('电子邮箱不可重复')}) diff --git a/template/app_admin/admin_user.html b/template/app_admin/admin_user.html index 9bbfe25..49f7dca 100644 --- a/template/app_admin/admin_user.html +++ b/template/app_admin/admin_user.html @@ -106,7 +106,7 @@ title:'新建用户', area:'300px;', id:'createUser',//配置ID - content:'
', + content:'
', btn:['确定','取消'], //添加按钮 btnAlign:'c', //按钮居中 yes:function (index,layero) { @@ -137,7 +137,7 @@ title:'新增管理员', area:'300px;', id:'createSuperUser',//配置ID - content:'
', + content:'
', btn:['确定','取消'], //添加按钮 btnAlign:'c', //按钮居中 yes:function (index,layero) { diff --git a/template/register.html b/template/register.html index ae6a1cb..96d52ca 100644 --- a/template/register.html +++ b/template/register.html @@ -65,7 +65,7 @@ {% endif %}
- +
@@ -75,7 +75,7 @@
- +