登录邮箱密码错误
Login with Email code error
为什么我无法成功登录..
views.py
def candidate_login(request):
if request.method == 'POST':
email = request.POST.get('email')
password = request.POST.get('password')
user = authenticate(email=email,password=password)
if user:
if user.is_active & user.check_password(password):
login(request,user)
return HttpResponseRedirect(reverse('index'))
else:
HttpResponse("Account not active, please contact Admin")
else:
print("Someone tried to login and failed")
return HttpResponse("Invalid login detailed supplied!")
else:
return render(request,'candidate_login.html',{})
当我尝试登录时收到 error
消息:提供的详细登录信息无效!
你能帮我让它工作吗?
非常感谢你
拉斐尔
models.py
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class MyUser(AbstractUser):
is_hr = models.BooleanField(default=False)
is_candidate = models.BooleanField(default=False)
is_employee = models.BooleanField(default=False)
company = models.CharField(max_length=100, default='')
authenticate 需要用户名和密码来验证。您可以直接过滤用户模型以获取与给定电子邮件链接的用户,然后 check_password 函数来验证密码。
def candidate_login(request):
if request.method == 'POST':
email = request.POST.get('email')
password = request.POST.get('password')
user = User.objects.filter(email=email)
if user:
user=user[0]
if user.is_active & user.check_password(password):
login(request,user)
return HttpResponseRedirect(reverse('index'))
else:
HttpResponse("Account not active, please contact Admin")
else:
print("Someone tried to login and failed")
return HttpResponse("Invalid login detailed supplied!")
else:
return render(request,'candidate_login.html',{})
为什么我无法成功登录..
views.py
def candidate_login(request):
if request.method == 'POST':
email = request.POST.get('email')
password = request.POST.get('password')
user = authenticate(email=email,password=password)
if user:
if user.is_active & user.check_password(password):
login(request,user)
return HttpResponseRedirect(reverse('index'))
else:
HttpResponse("Account not active, please contact Admin")
else:
print("Someone tried to login and failed")
return HttpResponse("Invalid login detailed supplied!")
else:
return render(request,'candidate_login.html',{})
当我尝试登录时收到 error
消息:提供的详细登录信息无效!
你能帮我让它工作吗? 非常感谢你 拉斐尔
models.py
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class MyUser(AbstractUser):
is_hr = models.BooleanField(default=False)
is_candidate = models.BooleanField(default=False)
is_employee = models.BooleanField(default=False)
company = models.CharField(max_length=100, default='')
authenticate 需要用户名和密码来验证。您可以直接过滤用户模型以获取与给定电子邮件链接的用户,然后 check_password 函数来验证密码。
def candidate_login(request):
if request.method == 'POST':
email = request.POST.get('email')
password = request.POST.get('password')
user = User.objects.filter(email=email)
if user:
user=user[0]
if user.is_active & user.check_password(password):
login(request,user)
return HttpResponseRedirect(reverse('index'))
else:
HttpResponse("Account not active, please contact Admin")
else:
print("Someone tried to login and failed")
return HttpResponse("Invalid login detailed supplied!")
else:
return render(request,'candidate_login.html',{})