mirror of https://github.com/veops/cmdb.git
fix jwt decode
This commit is contained in:
parent
048f556936
commit
87deba2e46
|
@ -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))
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -15,13 +15,13 @@ from api.lib.database import Model
|
|||
class RelationType(Model):
|
||||
__tablename__ = "c_relation_types"
|
||||
|
||||
name = db.Column(db.String(16), index=True)
|
||||
name = db.Column(db.String(16), index=True, nullable=False)
|
||||
|
||||
|
||||
class CITypeGroup(Model):
|
||||
__tablename__ = "c_ci_type_groups"
|
||||
|
||||
name = db.Column(db.String(32))
|
||||
name = db.Column(db.String(32), nullable=False)
|
||||
|
||||
|
||||
class CITypeGroupItem(Model):
|
||||
|
@ -35,12 +35,12 @@ class CITypeGroupItem(Model):
|
|||
class CIType(Model):
|
||||
__tablename__ = "c_ci_types"
|
||||
|
||||
name = db.Column(db.String(32))
|
||||
alias = db.Column(db.String(32))
|
||||
name = db.Column(db.String(32), nullable=False)
|
||||
alias = db.Column(db.String(32), nullable=False)
|
||||
unique_id = db.Column(db.Integer, db.ForeignKey("c_attributes.id"), nullable=False)
|
||||
enabled = db.Column(db.Boolean, default=True, nullable=False)
|
||||
is_attached = db.Column(db.Boolean, default=False, nullable=False)
|
||||
icon_url = db.Column(db.String(256))
|
||||
icon_url = db.Column(db.String(256), default='', nullable=False)
|
||||
order = db.Column(db.SmallInteger, default=0, nullable=False)
|
||||
|
||||
unique_key = db.relationship("Attribute", backref="c_ci_types.unique_id")
|
||||
|
@ -89,7 +89,7 @@ class CITypeAttribute(Model):
|
|||
class CITypeAttributeGroup(Model):
|
||||
__tablename__ = "c_ci_type_attribute_groups"
|
||||
|
||||
name = db.Column(db.String(64))
|
||||
name = db.Column(db.String(64), nullable=False)
|
||||
type_id = db.Column(db.Integer, db.ForeignKey("c_ci_types.id"), nullable=False)
|
||||
order = db.Column(db.SmallInteger, default=0)
|
||||
|
||||
|
@ -266,8 +266,8 @@ class OperationRecord(Model):
|
|||
__tablename__ = "c_records"
|
||||
|
||||
uid = db.Column(db.Integer, index=True, nullable=False)
|
||||
origin = db.Column(db.String(32))
|
||||
ticket_id = db.Column(db.String(32))
|
||||
origin = db.Column(db.String(32), nullable=False)
|
||||
ticket_id = db.Column(db.String(32), nullable=False)
|
||||
reason = db.Column(db.Text)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue