I am trying to use the django inbuilt AuthenticationForm to allow users to login using their email address and password. I have changed the authenticate function to accept both username and email to authenticate users.
This is my code so far:
def loginuser(request):
if request.POST:
"""trying to use AuthenticationForm to login and add validations"""
form = AuthenticationForm(request.POST.get('email'),request.POST.get('password'))
user = form.get_user()
if user.is_active:
login(request,user)
render_to_response('main.html',{'user':user})
else:
HttpResponse('user not active')
render_to_response('login.html')
But this is not how the authentication form is used, at least not the correct way.