app/auth/helpers.py
def auth_required(f):
    """Decorator to require auth token on marked endpoint"""

    @wraps(f)
    def decorated_function(*args, **kwargs):
        token = get_token_from_header()
        if not token:
            raise InvalidTokenError()

        if is_token_blacklisted(token):
            raise TokenExpiredError()

        token_payload = decode_auth_token(token)

        current_user = User.query.filter_by(id=token_payload["sub"]).first()
        if not current_user:
            raise InvalidTokenError()

        return f(*args, **kwargs)

    return decorated_function
Decorator to require auth token on marked endpoint
Decorator to require auth token on marked endpoint
Decorator to require auth token on marked endpoint
def auth_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        token = get_token_from_header()
        if not token:
            raise InvalidTokenError()
        if is_token_blacklisted(token):
            raise TokenExpiredError()
        token_payload = decode_auth_token(token)
        current_user = User.query.filter_by(id=token_payload["sub"]).first()
        if not current_user:
            raise InvalidTokenError()
        return f(*args, **kwargs)
    return decorated_function
def auth_required ( f ) : @ wraps ( f ) def decorated_function ( * args , ** kwargs ) : token = get_token_from_header ( ) if not token : raise InvalidTokenError ( ) if is_token_blacklisted ( token ) : raise TokenExpiredError ( ) token_payload = decode_auth_token ( token ) current_user = User . query . filter_by ( id = token_payload [ "sub" ] ) . first ( ) if not current_user : raise InvalidTokenError ( ) return f ( * args , ** kwargs ) return decorated_function
Decorator to require auth token on marked endpoint
Decorator to require auth token on marked endpoint
"""Decorator to require auth token on marked endpoint"""
f