Exemplo n.º 1
0
    def post(self, request):
        form = Form(request, data=request.body_data() or {})

        if form.is_valid():
            request.cache.auth_backend.logout(request)
            result = {'success': True}
        else:
            result = form.tojson()
        return self.json_response(request, result)
Exemplo n.º 2
0
    def post(self, request):
        form = Form(request, data=request.body_data() or {})

        if form.is_valid():
            request.cache.auth_backend.logout(request)
            result = {'success': True}
        else:
            result = form.tojson()
        return self.json_response(request, result)
Exemplo n.º 3
0
def logout(request):
    '''Logout a user
    '''
    form = Form(request, data=request.body_data() or {})

    if form.is_valid():
        user = request.cache.user
        auth_backend = request.cache.auth_backend
        return auth_backend.logout_response(request, user)
    else:
        return Json(form.tojson()).http_response(request)
Exemplo n.º 4
0
    def post(self, request):
        user = request.cache.user
        if not user.is_authenticated():
            raise PermissionDenied
        form = Form(request, data=request.body_data() or {})
        if form.is_valid():
            data = {'token': request.cache.session.token}
        else:
            data = form.tojson()

        return self.json_response(request, data)
Exemplo n.º 5
0
    def post(self, request):
        user = request.cache.user
        if not user.is_authenticated():
            raise PermissionDenied
        form = Form(request, data=request.body_data() or {})
        if form.is_valid():
            data = {'token': request.cache.session.token}
        else:
            data = form.tojson()

        return self.json_response(request, data)