Example #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)
Example #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)
Example #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)
Example #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)
Example #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)