Move the logout logic to the auth manager
__tracebackhide__ = True  
            appbuilder = current_app.appbuilder
            dag_id = (
                kwargs.get("dag_id")
                or request.args.get("dag_id")
                or request.form.get("dag_id")
                or (request.is_json and request.json.get("dag_id"))
                or None
            )
            if appbuilder.sm.check_authorization(permissions, dag_id):
                return func(*args, **kwargs)
            elif get_auth_manager().is_logged_in() and not g.user.perms:
                return (
                    render_template(
                        "airflow/no_roles_permissions.html",
                        hostname=get_hostname()
                        if conf.getboolean("webserver", "EXPOSE_HOSTNAME")
                        else "redact",
                        logout_url=appbuilder.get_url_for_logout,
                    ),
                    403,
                )
            else:
                access_denied = "Access is Denied"
                flash(access_denied, "danger")
            return redirect(get_auth_manager().get_url_login(next=request.url))
        return cast(T, decorated)
    return requires_access_decorator