def post(self, request, token): try: a = SlidingToken(token) a.blacklist() return redirect("https://www.w3schools.com") except TokenError: return HttpResponse("Token has been blacklisted")
def patch(self, request, email): data = JSONParser().parse(request) try: if email == getEmail(request) and getEmail( request) == data['email']: print('yes') password = make_password(data['password']) user = UserAccounts.objects.filter(email=data['email']) user.update(password=password) token = request.META.get('HTTP_AUTHORIZATION', '').split()[1] a = SlidingToken(token) a.blacklist() return JsonResponse({'msg': 'success'}) else: return JsonResponse({'msg': 'Fail'}) except TokenError: return JsonResponse({'msg': 'error'})
def post(self, request): token = request.META.get("HTTP_AUTHORIZATION", '').split()[1] tokens = SlidingToken(token) tokens.blacklist() return HttpResponse('the token is blackListed')