本文整理汇总了Python中constants.Constants.error_no_user_id方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.error_no_user_id方法的具体用法?Python Constants.error_no_user_id怎么用?Python Constants.error_no_user_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类constants.Constants
的用法示例。
在下文中一共展示了Constants.error_no_user_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_user_credentials_with_credentials
# 需要导入模块: from constants import Constants [as 别名]
# 或者: from constants.Constants import error_no_user_id [as 别名]
def check_user_credentials_with_credentials(user_id, token):
# Check token status
status = TokenSerializer.verify_auth_token(token, user_id)
# Is token is expired?
if status == SignatureExpired:
# Yes: return error status
return Constants.error_token_expired()
# Is toke not valid?
elif status == BadSignature:
# Yes: return error status
return Constants.error_token_not_valid()
# Try to find user with received ID
person_model = PersonModel.query.filter_by(person_id=user_id).first()
# Have we user with received ID?
if person_model is None:
# No we haven't: return error status
return Constants.error_no_user_id()
# Is received token correct?
if person_model.token != token:
# No: return error status
return Constants.error_token_not_valid()
# If everything is Ok - return person model
return person_model