This commit is contained in:
Bob 2020-08-20 22:53:57 +08:00
parent 23d2d43d3d
commit 2e8820508a
2 changed files with 45 additions and 44 deletions

View File

@ -48,6 +48,7 @@ def user_login(request):
except CaptchaStore.DoesNotExist: except CaptchaStore.DoesNotExist:
messages.error(request, '验证码错误') messages.error(request, '验证码错误')
return HttpResponseRedirect('/login/') return HttpResponseRedirect('/login/')
print(username,password)
if username is not None and password is not None: if username is not None and password is not None:
try: try:
# user = authenticate(username=username, password=password) # user = authenticate(username=username, password=password)
@ -61,7 +62,7 @@ def user_login(request):
else: else:
messages.error(request, '账号或密码错误,请您确认账号和密码') messages.error(request, '账号或密码错误,请您确认账号和密码')
except: except:
messages.error(request, '账号或密码错误,请您确认账号和密码') messages.error(request, '111')
return render(request,'dashboard/login.html',{'hash_key':hash_key,'image_url':image_url}) return render(request,'dashboard/login.html',{'hash_key':hash_key,'image_url':image_url})
def user_logout(request): def user_logout(request):
logout(request) logout(request)

View File

@ -1,6 +1,6 @@
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse, JsonResponse from django.http import HttpResponse, JsonResponse
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model, authenticate, login
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
# Create your views here. # Create your views here.