fix jwt decode

This commit is contained in:
pycook
2020-02-06 09:59:24 +08:00
parent 048f556936
commit 87deba2e46
4 changed files with 18 additions and 10 deletions

View File

@@ -40,7 +40,9 @@ class CITypeManager(object):
@staticmethod
def check_is_existed(key):
return CITypeCache.get(key) or abort(404, "CIType <{0}> is not existed".format(key))
ci_type = CITypeCache.get(key) or abort(404, "CIType <{0}> is not existed".format(key))
return CIType.get_by_id(ci_type.id)
@staticmethod
def get_ci_types(type_name=None):
@@ -65,6 +67,9 @@ class CITypeManager(object):
else:
return
if not ci_type:
return
if type_id is not None and ci_type.id != type_id:
return abort(400, "CIType <{0}> is already existed".format(name or alias))

View File

@@ -25,6 +25,9 @@ class FormatMixin(object):
class CRUDMixin(FormatMixin):
def __init__(self, **kwargs):
super(CRUDMixin, self).__init__(**kwargs)
@classmethod
def create(cls, flush=False, **kwargs):
return cls(**kwargs).save(flush=flush)

View File

@@ -47,7 +47,7 @@ def _auth_with_token():
try:
token = auth_headers
data = jwt.decode(token, current_app.config['SECRET_KEY'])
data = jwt.decode(token, current_app.config['SECRET_KEY'], algorithms=['HS256'])
user = User.query.filter_by(email=data['sub']).first()
if not user:
return False