How to Login with Phone Number

40 views
Skip to first unread message

SAM

unread,
May 19, 2022, 6:47:52 AM5/19/22
to django-oscar
I add custom phone files to my user model

class User(AbstractUser):
    phone_number = PhoneNumberField(_("Phone number"), blank=True, unique=True,help_text=_("In case we need to call you"))

and I use Oscar API

now, how can I log in using phone number and email.

Viggo de Vries

unread,
May 19, 2022, 9:19:41 AM5/19/22
to django-oscar
Hey Sam,

I think you'll want to look into customizing the Django authentication backend: https://docs.djangoproject.com/en/4.0/topics/auth/customizing/

You can add your own authentication backend that tries loggin in with email and password first, after that you would try logging in with phone number and password.

Let me know if this helped!

Op donderdag 19 mei 2022 om 12:47:52 UTC+2 schreef SAM:

SAM

unread,
May 23, 2022, 2:34:06 AM5/23/22
to django-oscar

Thanks for that.
Already made custom authentication based on Modelbackend
Screenshot 2022-05-23 123303.png

and add this to AUTHENTICATION_BACKENDS

It works fine now.

Thanks for that./

Reply all
Reply to author
Forward
0 new messages