So I'm building a multi-tenant Firebase application using Flutter. I know, Firebase recommends against this, but it is supported through Google Cloud Identity Platform.
I've set up GCIP and I can log in global users that don't belong to a tenant. I can also log in users that belong to a tenant, as long as I know their tenantId ahead of time.
FirebaseAuth auth1 = FirebaseAuth.instance;
auth1.tenantId = "tenant1";
auth1.signInWithEmailAndPassword(
email: "user@tenant1.com", password: "password");
print('${auth1.currentUser?.tenantId}'); // prints "tenant1"
The approach described in the Google Cloud docs has the user select their organization/tenant from a dropdown list, but I think this approach is a bad user experience and would quickly become unwieldy once you have more than a few tenants.
Ideally, a user should be able to log in and be directed to the right tenant.
Is there any way to achieve this? Any help would be greatly appreciated!
(PS. I can't rely on custom URLs since this is a mobile app)