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

Custom user-mobile field #113

Open
nate-sha opened this issue May 20, 2022 · 2 comments
Open

Custom user-mobile field #113

nate-sha opened this issue May 20, 2022 · 2 comments

Comments

@nate-sha
Copy link

Hi,

This is most likely not an issue rather than a problem that I could not find an answer for, thank you in advance :-)

Error: django.core.exceptions.FieldError: Cannot resolve keyword 'mobile' into field

Setup: The user mobile field lives in a separate "Profile" model that has an OneToOne relation with the User model, to get the "mobile" values, I usually do User.profile.mobile; I am currently using this to return the authenticated user's full profile.

I tried the following values for PASSWORDLESS_USER_MOBILE_FIELD_NAME and it did not work

  • PASSWORDLESS_USER_MOBILE_FIELD_NAME: 'profile.mobile'
  • PASSWORDLESS_USER_MOBILE_FIELD_NAME: 'Profile.mobile'
  • PASSWORDLESS_USER_MOBILE_FIELD_NAME: 'User.profile.mobile'

Do I need to override/use my own "send_sms_with_callback_token"
to_number = getattr(user, api_settings.PASSWORDLESS_USER_MOBILE_FIELD_NAME)
if to_number.class.name == 'PhoneNumber':
to_number = to_number.str()

Thanks

@phoorooz
Copy link

same issue

@H1ako
Copy link

H1ako commented Feb 10, 2023

I think it's a bug. I checked the code and this line causing the error.

            if api_settings.PASSWORDLESS_REGISTER_NEW_USERS is True:
                # If new aliases should register new users.
                try:
                    user = User.objects.get(**{self.alias_type+'__iexact': alias})  # it looks for alias_type for mobile field that is always 'mobile'
                    # same with email. Always 'email' check
                except User.DoesNotExist:
                    user = User.objects.create(**{self.alias_type: alias})
                    user.set_unusable_password()
                    user.save()
            else:
                # If new aliases should not register new users.
                try:
                    user = User.objects.get(**{self.alias_type+'__iexact': alias})
                except User.DoesNotExist:
                    user = None

made PR #131

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

3 participants