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")
示例#2
0
 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'})
示例#3
0
 def post(self, request):
     token = request.META.get("HTTP_AUTHORIZATION", '').split()[1]
     tokens = SlidingToken(token)
     tokens.blacklist()
     return HttpResponse('the token is blackListed')