示例#1
0
    def is_payable(cls, point: int, level: int) -> PayStatus:
        if point < 0:
            raise ForbiddenException()

        if level > 0:
            return PayStatus.STAFF

        return PayStatus.HAS_MONEY
示例#2
0
 def delete_music_apply(student_id: str, apply_id: int):
     apply: 'MusicApplyModel' = MusicApplyModel.query.filter_by(
         id=apply_id).first()
     if apply is None:
         raise NoContentException()
     if apply.student_id != student_id:
         raise ForbiddenException()
     apply.delete()
示例#3
0
    def _verify_refresh_token(cls, refresh_token, user_agent):
        token = TokenModel.query.filter_by(owner=get_jwt_identity(),
                                           refresh_token=refresh_token,
                                           user_agent=user_agent).first()

        if not token:
            raise ForbiddenException()

        return token
示例#4
0
    def change_pw(id: str, current_pw: str, new_pw: str):
        student: StudentModel = StudentModel.get_student_by_id(id)
        if student is None:
            raise WrongAuthException()

        if not check_password_hash(student.pw, current_pw):
            raise ForbiddenException()

        if check_password_hash(student.pw, new_pw):
            raise ResetContentException()

        student.pw = generate_password_hash(new_pw)
        db.session.commit()