[Django]-Django authentication failing with a 403 with no detailed message

2👍

✅

It was all because of Django’s built-in CSRF system: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/

1👍

Well, one thing you do is

from django.contrib.auth import authenticate,login,logout

and then redefine login

def login(request):

and then call the other one again, which is not reachable anymore (overwritten by your own login function).

login(request, user)

Not sure though if that’s causing the error though.

0👍

Also, the line:

return User.objects.get(email_address=email_address, password=password)

implies that the User record stores the password as-is, in plaintext. Whereas, in fact, it stores a salted hash of the password, so you might need to implement all that functionality yourself.

Leave a comment