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