Beispiel #1
0
    def finish_wizard(self):
        identity = self.provider.build_identity(self.state.data)

        defaults = {
            'valid': True,
            'scopes': identity.get('scopes', []),
            'data': identity.get('data', {}),
            'last_verified': timezone.now(),
        }

        user = self.get_or_create_user(identity=identity)
        _, created = SSOIdentity.objects.update_or_create(
            provider=self.provider.key,
            user=user,
            external_id=identity['id'],
            defaults=defaults,
        )

        if created:
            auditor.record(event_type=self.provider.event_type, instance=user)

        self.state.clear()

        response = HttpResponseRedirect('/')
        login_user(request=self.request,
                   response=response,
                   user=user,
                   login=True)
        return response
Beispiel #2
0
    def finish_wizard(self):
        identity = self.provider.build_identity(self.state.data)

        defaults = {
            'valid': True,
            'scopes': identity.get('scopes', []),
            'data': identity.get('data', {}),
            'last_verified': timezone.now(),
        }

        user = self.get_or_create_user(identity=identity)
        _, created = SSOIdentity.objects.update_or_create(
            provider=self.provider.key,
            user=user,
            external_id=identity['id'],
            defaults=defaults,
        )

        if created:
            auditor.record(event_type=self.provider.event_type, instance=user)

        self.state.clear()

        response = HttpResponseRedirect('/')
        login_user(request=self.request, response=response, user=user, login=True)
        return response
Beispiel #3
0
 def dispatch(self, request, *args, **kwargs):
     if not request.user.is_anonymous:
         return HttpResponseRedirect('/')
     response = super().dispatch(request, *args, **kwargs)
     login_user(request=request,
                response=response,
                user=request.user,
                login=False)
     return response
Beispiel #4
0
 def dispatch(self, request, *args, **kwargs):
     if not request.user.is_anonymous:
         return HttpResponseRedirect('/')
     response = super(LoginView, self).dispatch(request, *args, **kwargs)
     login_user(request=request, response=response, user=request.user, login=False)
     return response