How to automatically select organizations during login?

Hi,

I have the following setup:

  • 1 tenant
  • 1 database connection (right now)
  • Multiple served companies currently stored in user’s app_metadata but I want to migrate it to Organizations.
  • Every user belongs to just one company.
    I went through the documentation and the Organization feature looks like a good fit for our use case but I have an issue with that. I don’t want to complicate the user’s login flow with the ‘give me your organization ID’ step but without that, I couldn’t have him logged in to his org. Is there any way to make this automatic?

Regards,
Laszlo

Hi Laszlo -

Were you able to figure this out? I’m wondering the same thing. I’ve found you can switch between organizations using getAccessTokenSilently({organization: 'ORG_ID', ignoreCache: true}), but only if the user initially logs in with an organization. It doesn’t work if they login as an individual (i.e. skipping the org selector).

If it allowed you to move from an individual login to an org login you could:

  1. Have the user login as an individual.
  2. Query your API for their organization.
  3. Use getAccessTokenSilently to get an access token for that org

@konrad.sopala I’ve seen you comment on other organizations threads. Any thoughts here?

The question boils down to - when using orgs - is there any way to have the user login, then get an access token for a particular organization within the application? Or does the user always need to first enter the organization name?

This seems like a very reasonable, common, usecase and it’s not documented well in the organization docs.