def handle_anonymous_user(self, response): """ Handles the ULogin response if user is not authenticated (anonymous) """ try: ulogin = ULoginUser.objects.get(network=response['network'], uid=response['uid']) except ULoginUser.DoesNotExist: user = create_user(request=self.request, ulogin_response=response) ulogin = ULoginUser.objects.create(user=user, network=response['network'], identity=response['identity'], uid=response['uid']) registered = True else: user = ulogin.user registered = False # Authenticate user if not hasattr(user, 'backend'): user.backend = settings.AUTHENTICATION_BACKEND login(self.request, user) return user, ulogin, registered