Skip to content

Commit 4bc62c2

Browse files
committed
开启验证码功能
1 parent 26d68fa commit 4bc62c2

16 files changed

+29
-412
lines changed

commons/views.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ def login(request):
5050
de_password = crypt.de_js_encrypt(password)
5151

5252
login_ip = request.META.get('REMOTE_ADDR')
53-
# code = request.POST.get('code')
53+
code = request.POST.get('code')
5454
remember_me = request.POST.get('remember_me')
55-
# if code.lower() != request.session.get('check_code', 'error').lower():
56-
# return render(request, 'login.html', {"login_error_info": "验证码错误,请重新输入!"})
55+
if code.lower() != request.session.get('check_code', 'error').lower():
56+
return render(request, 'login.html', {"login_error_info": "验证码错误,请重新输入!", 'public_key': crypt.gen_pri_pub_key})
5757
user = auth.authenticate(username=username, password=de_password)
5858
if user and user.is_active:
5959
auth.login(request, user)
@@ -91,6 +91,7 @@ def logout(request):
9191

9292

9393
def lock_screen(request):
94+
crypt = CryptPwd()
9495
if request.method == 'GET':
9596
user = UserProfile.objects.get(username=request.user)
9697
UserProfile.objects.filter(username=request.user).update(
@@ -99,15 +100,17 @@ def lock_screen(request):
99100
request.session['lock'] = 'lock'
100101
if 'lock_screen' not in request.META.get('HTTP_REFERER'):
101102
request.session['referer_url'] = request.META.get('HTTP_REFERER')
103+
public_key = crypt.gen_pri_pub_key
102104
return render(request, 'lockscreen.html', locals())
103105
elif request.method == 'POST':
104-
de_password = CryptPwd().de_js_encrypt(request.POST.get('pwd'))
106+
de_password = crypt.de_js_encrypt(request.POST.get('pwd'))
105107
user = auth.authenticate(username=request.session['username'], password=de_password)
106108
if user:
107109
del request.session['lock']
108110
referer_url = request.session.get('referer_url')
109111
return redirect(referer_url)
110-
return render(request, 'lockscreen.html', {"login_error_info": "密码错误!请确认输入的密码是否正确!"}, )
112+
return render(request, 'lockscreen.html',
113+
{"login_error_info": "密码错误!请确认输入的密码是否正确!", 'public_key': crypt.gen_pri_pub_key})
111114

112115

113116
@admin_auth
File renamed without changes.

static/login/css/goole.css

-92
This file was deleted.

static/login/css/li.css

-82
This file was deleted.

static/login/images/404.png

-21.1 KB
Binary file not shown.

static/login/images/404_bg.jpg

-100 KB
Binary file not shown.

static/login/images/log_06.png

-1.3 KB
Binary file not shown.

static/login/images/log_08.png

-1.35 KB
Binary file not shown.

static/login/images/log_i_03.png

-1.44 KB
Binary file not shown.

static/login/images/op_login.png

-26.8 KB
Binary file not shown.

static/login/images/operation_bg.jpg

-424 KB
Binary file not shown.

static/login/js/jquery-1.7.2.min.js

-4
This file was deleted.

0 commit comments

Comments
 (0)