handleLoginWithTenants method
Processes tenant list after successful authentication.
This method handles the post-authentication flow based on the number of tenants the user has access to:
- If exactly one tenant: automatically selects it
- If multiple tenants: shows tenant selection UI
- If no tenants: displays an error
Parameters:
tenants: List of tenants the authenticated user has access to
Implementation
Future<void> handleLoginWithTenants(List<Tenant> tenants) async {
if (tenants.isNotEmpty) {
if (tenants.length == 1) {
add(LoginWithSelectedTenantEvent(tenant: tenants.first));
return;
}
add(LoginWithMultipleTenantsEvent(tenants));
return;
}
add(const AuthenticationErrorEvent(
title: 'Không tìm thấy ứng dụng',
message: 'Không tìm thấy ứng dụng được phép truy cập',
error: null,
));
}