Guest access decorator
    Checks if public profiles option is enabled in config and checks
    access to profile pages based on that.

def guest_access(func):
    """
    Guest access decorator
    Checks if public profiles option is enabled in config and checks
    access to profile pages based on that.
    """
    def decorated(*_, **kwargs):
        public_profiles = current_app.config['USER_PUBLIC_PROFILES']
        if not public_profiles:
            if not current_user.is_authenticated:
                abort(401)
            elif current_user.id != kwargs['id']:
                abort(403)
        return func(**kwargs)

    return decorated