A wrapper around the flask_login.login_required.
    But it also checks the presence of the decorator: @login_not_required
    On a "@login_required" class, method containing "@login_not_required" will
    still be able to access without authentication
    :param func:
    :return:

def login_required(func):
    """
    A wrapper around the flask_login.login_required.
    But it also checks the presence of the decorator: @login_not_required
    On a "@login_required" class, method containing "@login_not_required" will
    still be able to access without authentication
    :param func:
    :return:
    """
    if inspect.isclass(func):
        apply_function_to_members(func, login_required)
        return func
    else:
        @functools.wraps(func)
        def decorated_view(*args, **kwargs):
            if "login_not_required" not in utils.get_decorators_list(func) \
                    and not_authenticated():
                return login_manager.unauthorized()
            return func(*args, **kwargs)

        return decorated_view