Exemplo n.º 1
0
 def _login(self, user, expiration, form):
     login(self.request,
           user,
           expiration,
           allowed_cookie=self.allowed_cookie,
           allowed_header=self.allowed_header,
           two_factor_login=True)
Exemplo n.º 2
0
    def post(self, request, *args, **kwargs):
        serializer = self.serializer_class(data=request.data,
                                           context={'request': request})
        serializer.is_valid(raise_exception=True)
        user = serializer.validated_data['user']

        login(
            request._request, user, not serializer.validated_data.get('permanent', False),
            allowed_cookie=self.allowed_cookie, allowed_header=self.allowed_header
        )
        return Response({'token': request._request.token.key})