human
Complete this python program:
def login_required(func, login_url=None, redirect=REDIRECT_FIELD_NAME, only_active=True):
assistant
#Here is the Python program you requested.

    """Requires that the user is logged in.
    """
    if only_active:
        def redirect_func(user):
            return (not (user.is_authenticated() and user.is_active))
    else:
        def redirect_func(user):
            return (not user.is_authenticated())
    return user_access_decorator(redirect_func, redirect_field=redirect, redirect_url_func=(lambda : login_url))(func)