Commit 7110f9c9 authored by Fence's avatar Fence 🌈

fix DoesNotExist exception

parent 0e5eda33
......@@ -8,12 +8,17 @@ class CryptoChecker(object):
def check(self, token):
payload = jwt.decode(token, "", verify=False)
issuer = MajorInstance.objects.get(issuer=payload["iss"])
try:
issuer = MajorInstance.objects.get(issuer=payload["iss"])
except MajorInstance.DoesNotExist:
return None
if issuer is not None:
try:
key = issuer.key
checked_payload = jwt.decode(token, key)
return checked_payload
except Exception as e:
print(e)
return None
return None
......@@ -10,7 +10,7 @@ def auth_required(f):
if auth is not None:
auth = auth.split(" ")
if auth[0] == "Bearer":
print(auth[1])
# print(auth[1])
payload = CryptoChecker("minor").check(auth[1])
if payload is not None:
kwargs["payload"] = payload
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment