django-rest-framework-passwordless
django-rest-framework-passwordless copied to clipboard
PASSWORDLESS_USER_MOBILE_FIELD_NAME on CustomUser
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'
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.
https://github.com/aaronn/django-rest-framework-passwordless/blob/7fe00dfbef8d163078160c7f317b26ed630fc8cc/drfpasswordless/serializers.py#L47
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!
This what I did and it worked
in your settings.py
'PASSWORDLESS_USER_MOBILE_FIELD_NAME': 'mobile'

In your models.py
@ankitksr I don't think it a bug
@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.
@ankitksr it is a bug which need to resolve in drfpasswordless .