Multitype authentication system

hey can any one have idea how to create auth system in django like instagram (login with : username,phone number or email ) any idea plz and thanks in advance

I don’t use instagram, so saying you want to do something like it doesn’t describe your requirements to me.

It sounds like you want to have a login page where the person can enter in any of their username, phone number, or email address and it will authenticate them using that identifier.

If so, then this is relatively easy.

If you look at the example at How to log a user in, you’ll see that the basic process gets the username from what is entered in the login form.

You need to change that to find the username based on what is entered possibly matching more than one field, and you can do that with a query.
Example:

identifier = request.POST['username']
# Note: You'll probably want to do something different here 
# for real to handle the case where the user isn't found, 
# or if multiple records are returned.
login_user = User.objects.get(
    Q(username=identifier) | 
    Q(email=identifier) |
    Q(phone_number=identifier)
)
username = login_user.username
user = authenticate(...
1 Like