Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Allow logging in with phone number, email or username #206

Closed
4 tasks
nemesifier opened this issue Dec 10, 2020 · 4 comments · Fixed by #208
Closed
4 tasks

[feature] Allow logging in with phone number, email or username #206

nemesifier opened this issue Dec 10, 2020 · 4 comments · Fixed by #208
Assignees

Comments

@nemesifier
Copy link
Member

nemesifier commented Dec 10, 2020

Right now is only possible to log in with the username, but nowadays email and phone numbers are widely used.

We need to create an authentication backend that allows authenticating with any of the following:

  • username
  • email
  • phone number

And of course, password.

Important points:

  • the string supplied for username, email or phone number must be not empty.
  • we could use an OR query, in order of precedence: get user with this email or this phone number or this username
  • it's possible the query will return multiple results, the precedence of the previous point should be respected: write a test in which user A has username: user@test.com and user B has email user@test.com, test the authentication backend and ensure user B gets authenticated correctly
  • write a similar test like the one before but with a phone number
@pandafy
Copy link
Member

pandafy commented Dec 11, 2020

  • it's possible the query will return multiple results, the precedence of the previous point should be respected: write a test in which user A has username: user@test.com and user B has email user@test.com, test the authentication backend and ensure user B gets authenticated correctly
  • write a similar test like the one before but with a phone number

We can just make such occurrence obsolete by putting regex in place which ensure that user can't put an email address or mobile number(a username should contain atleast one alphabet) in username field.

We should explore whether django-allauth could do the heavy lifting for us instead of creating our own authentication backend.

@NoumbissiValere
Copy link
Contributor

  • it's possible the query will return multiple results, the precedence of the previous point should be respected: write a test in which user A has username: user@test.com and user B has email user@test.com, test the authentication backend and ensure user B gets authenticated correctly
  • write a similar test like the one before but with a phone number

We can just make such occurrence obsolete by putting regex in place which ensure that user can't put an email address or mobile number(a username should contain atleast one alphabet) in username field.

@pandafy we want to able to put an email or a phone number in the place of username and still get logged in.

@pandafy
Copy link
Member

pandafy commented Dec 11, 2020

@pandafy we want to able to put an email or a phone number in the place of username and still get logged in.

Thanks for clearing out @NoumbissiValere 😄

@nemesifier
Copy link
Member Author

@pandafy changing the authentication backend is the standard practice, why do you think is better doing it differently?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

3 participants