def migrate_google_openid_user(user): with transaction.atomic(): if user and is_user_lazy(user): return None try: new_social = UserSocialAuth.objects.get(user_id=user.id, provider='google-oauth2') except UserSocialAuth.DoesNotExist: return None try: old_social = UserSocialAuth.objects.get(uid=user.email, provider='google') new_user = new_social.user new_social.user = old_social.user new_social.save() # in case of already migrated users do not lose data if new_user.id != old_social.user.id: new_user.delete() old_social.delete() LOGGER.info( 'Migrating user "{}" from Google OpenID to OAauth2'.format( user.email)) return old_social.user except UserSocialAuth.DoesNotExist: return None
def migrate_google_openid_user(user): with transaction.atomic(): if user and is_user_lazy(user): return None try: new_social = UserSocialAuth.objects.get(user_id=user.id, provider='google-oauth2') except UserSocialAuth.DoesNotExist: return None try: old_social = UserSocialAuth.objects.get(uid=user.email, provider='google') new_user = new_social.user new_social.user = old_social.user new_social.save() # in case of already migrated users do not lose data if new_user.id != old_social.user.id: new_user.delete() old_social.delete() LOGGER.info('Migrating user "{}" from Google OpenID to OAauth2'.format(user.email)) return old_social.user except UserSocialAuth.DoesNotExist: return None
def init_user_profile(sender, instance, created=False, **kwargs): if is_user_real(instance) and not is_user_lazy(instance): UserProfile.objects.get_or_create(user=instance)
def drop_lazy_user(sender, instance, created=False, **kwargs): if is_user_real(instance) and is_user_lazy(instance): convert_lazy_user(instance)
def init_user_profile(sender, instance, created=False, **kwargs): if is_user_real(instance) and not is_user_lazy(instance): UserProfile.objects.get_or_create(user=instance)
def drop_lazy_user(sender, instance, created=False, **kwargs): if is_user_real(instance) and is_user_lazy(instance): convert_lazy_user(instance)