I want to check three fields before logging in. Username and password are default in authenticate function but I want to check whether user is live member or not. I have created field is_live in auth_user model. But when I put this third argument in authenticate function, it only check username and password field and ignore the third parameter of is_live.
I have used decorator of is_staff i.e., staff_member_required. Similarly I tried to reuse this decorator with is_live. But it didnt work. Now simply I want to check three parameters within authenticate function, username, password and is_live.
def login_user(request):
if request.method=="POST":
username=request.POST.get('phone')
password=request.POST.get('psw')
if not User.objects.filter(username=username).exists():
messages.error(request,'invalid username')
return redirect('/login_form/')
user=authenticate(username=username,password=password,is_staff=1)#three params
if user is None:
messages.error(request,"invalid password")
return redirect('/login_form/')
else:
login(request,user)
return redirect('/index')
#return HttpResponseRedirect(reverse("index"))
return HttpResponse("error")