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

PASSWORDLESS_USER_MOBILE_FIELD_NAME on CustomUser #54

Open
InzGIBA opened this issue Mar 27, 2020 · 5 comments
Open

PASSWORDLESS_USER_MOBILE_FIELD_NAME on CustomUser #54

InzGIBA opened this issue Mar 27, 2020 · 5 comments

Comments

@InzGIBA
Copy link

InzGIBA commented Mar 27, 2020

If I understand everything correctly, the property "PASSWORDLESS_USER_MOBILE_FIELD_NAME", helps to specify the name of your field

Cannot resolve keyword 'mobile' into field

settings.py:

PASSWORDLESS_AUTH = {
    'PASSWORDLESS_REGISTER_NEW_USERS': False,
    'PASSWORDLESS_USER_MOBILE_FIELD_NAME': 'phone_number',
    'PASSWORDLESS_AUTH_TYPES': ['MOBILE'],
}

models.py:

class CustomUser():
    uuid = models.UUIDField()
    phone_number = models.CharField()

    USERNAME_FIELD = 'phone_number'
@ankitksr
Copy link

ankitksr commented Aug 4, 2020

I faced the same problem.

The issue is that though the PASSWORDLESS_USER_MOBILE_FIELD_NAME allows to provide a custom phone number field; the below code uses the alias_type for querying the User queryset.

user = User.objects.get(**{self.alias_type+'__iexact': alias})

Since the alias_type variable alternates between 'mobile' or 'email'; we are essentially allowed to use only those two as field names.

@aaronn Please let me know if this is a valid issue and I can potentially raise a pr fixing this.

Thanks!

@jaymes15
Copy link

This what I did and it worked

in your settings.py

'PASSWORDLESS_USER_MOBILE_FIELD_NAME': 'mobile'
Screen Shot 2022-02-28 at 1 45 23 PM

In your models.py

Screen Shot 2022-02-28 at 1 44 32 PM

@jaymes15
Copy link

@ankitksr I don't think it a bug

@bprachi27
Copy link

@InzGIBA hii,
i am also facing same problem.
my model has email_id field instated of email.
I simply made my serializer and view inherit passwordless serializer and view. and I override alias_type function and i change email to 'email_id' and it worked really fine.

@bprachi27
Copy link

@ankitksr it is a bug which need to resolve in drfpasswordless .

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

No branches or pull requests

4 participants