Question

I'm using the django-email-as-username app for using email rather than username for authentication, and it works like a charm.

Now, in view I want to call

if request.user.is_authenticated()

but this method just authenticate users based upon (username+password) and not (email+password). How should I deal with this ?

Any suggestion ?

Was it helpful?

Solution

In Django the is_authenticated() always returns True for User instances and always returns False for AnonymousUser instances. It has nothing to do with username/password/email and django-email-as-username does not change this behaviour.

See the Django's source code:

# In User class line 279
def is_authenticated(self):
    """
    Always return True. This is a way to tell if the user has been
    authenticated in templates.
    """
    return True
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top