Fix nginx_jwt_resp HTTP responses
This commit is contained in:
+2
-2
@@ -339,13 +339,13 @@ class SignupViewSet(ModelViewSet):
|
||||
def nginx_jwt_resp(request, *args, **kwargs):
|
||||
accessKey = request.COOKIES.get("jwt_access", None)
|
||||
if not accessKey:
|
||||
return HttpResponse("", status=401)
|
||||
return HttpResponse("No valid access token", status=401)
|
||||
try:
|
||||
# This also verifies the signature.
|
||||
# See https://pyjwt.readthedocs.io/en/latest/usage.html#reading-the-claimset-without-validation
|
||||
token = decode(accessKey, settings.SECRET_KEY, algorithms=["HS256"])
|
||||
except InvalidTokenError:
|
||||
return HttpResponse("", status=403)
|
||||
return HttpResponse("Invalid access token", status=401)
|
||||
user = "admin" if token.get("username", "") == "admin" else "moderator"
|
||||
resp = HttpResponse("", status=200)
|
||||
resp["X-FBrowser-User"] = user
|
||||
|
||||
Reference in New Issue
Block a user