Move the logout logic to the auth manager
#
#
#
from __future__ import annotations
from flask import url_for
from flask_login import current_user
from airflow import AirflowException
from airflow.auth.managers.base_auth_manager import BaseAuthManager
from airflow.auth.managers.fab.models import User
from airflow.auth.managers.fab.security_manager_override import FabAirflowSecurityManagerOverride
class FabAuthManager(BaseAuthManager):
    """
    Flask-AppBuilder auth manager.
    This auth manager is responsible for providing a backward compatible user management experience to users.
    """
    def get_user_name(self) -> str:
        """
        Return the username associated to the user in session.
        For backward compatibility reasons, the username in FAB auth manager is the concatenation of the
        first name and the last name.
        """
        user = self.get_user()
        first_name = user.first_name or ""
        last_name = user.last_name or ""
        return f"{first_name} {last_name}".strip()
    def get_user(self) -> User: