0

Iam using django-allauth with dj-rest-auth with the apple provider. The strange issue only happens in production. After getting the token from apple for verifying the user, i send it to the django backend. I made a custom adapter which is appended from DefaultSocialAccountAdapter and override the save_user function:

class SocialAccountAdapter(DefaultSocialAccountAdapter):
    def save_user(self, request, sociallogin, form=None):
        user = super().save_user(request, sociallogin, form)

        profile = Profile.objects.get_or_create(user=user)

        url = sociallogin.account.get_avatar_url()
        avatar = download_file_from_url(url) if url else None
        if avatar is not None:
            avatar_obj = UserImageAvatar(
                file=avatar,
                creator=user
            )

            with atomic():
                avatar_obj.save()
                image = UserImageAvatar.objects.get(id=avatar_obj.id)
                user.profile.avatar = image
                user.profile.save(update_fields=['avatar'])

        return user

setting.py

SOCIALACCOUNT_ADAPTER = 'core.adapters.SocialAccountAdapter'

for creating a profile after the user is created. Locally it works all just fine. But in production, the user will be created, but without a username and without a profile, maybe the adapter is not be user? Settings are the same as in debug.

I am really slowly at the end and would be happy about any little hint or help

Viktor Isacenko
  • 143
  • 1
  • 7

0 Answers0