The entra tenant_id is programmatically available at UMTS::Auth.tenant_id.
tenant_id
UMTS::Auth.tenant_id
You can add a callback to the login action through after_authenticated which is an alias for after_action only: :create.
after_authenticated
after_action only: :create