Example #1
0
 def post(self):
     jti = get_raw_jwt()['jti']
     try:
         revoked_token = RevokedToken(jti=jti)
         revoked_token.add()
         return {'message': 'logged out successfully'}
     except:
         return {'message': 'Something went wrong'}, 500
Example #2
0
 def post(self):
     jti = get_raw_jwt()['jti']
     try:
         revoked_token = RevokedToken(jti=jti)
         revoked_token.add()
         return {'message': 'Refresh token has been revoked'}
     except:
         return {'message': 'Something went wrong'}, 500
Example #3
0
def revoke_token(user: Journalist, auth_token: str) -> None:
    try:
        revoked_token = RevokedToken(token=auth_token, journalist_id=user.id)
        db.session.add(revoked_token)
        db.session.commit()
    except IntegrityError as e:
        db.session.rollback()
        if "UNIQUE constraint failed: revoked_tokens.token" not in str(e):
            raise e
Example #4
0
def revoke_token(user: Journalist, auth_token: str) -> None:
    revoked_token = RevokedToken(token=auth_token, journalist_id=user.id)
    db.session.add(revoked_token)
    db.session.commit()
Example #5
0
def revoke_token(user, auth_token):
    revoked_token = RevokedToken(token=auth_token, journalist_id=user.id)
    db.session.add(revoked_token)
    db.session.commit()
Example #6
0
def check_token(decrypted_token):
    jti = decrypted_token['jti']
    return RevokedToken.is_jti_blacklisted(jti)