How to avoid the organization name prompt

Hi There,

We are building a b2b SaSS application. All the clients will have their own subdomains(ex: https://<client_name>.app.com).

As it’s a SaSS application we use the same application for different organizations, we would like to avoid the organization prompt.

As far as my understanding after reading the docs, if we want to avoid organization promopt we need to pass organizationId when we redirecting the user to /authorize.

So we come with a solution that, we read the browser url and get sub domain using javscript and pass that to backend api.

backend api is responsible for geting the org Id using the org name and forward it to front end as a reponse.

Are we going in right direction to avoid the promp?

Thanks in advance for your help.

Cheers
Kishor

We have the same use-case and the approach that you described is what we’ve also used:

  • We have a mapping table that can resolve an organisation name (which can be found in the subdomain) to an organisation id. This organisation id is then passed to /authorize in order to bypass the organisation prompt. It would be easier if Auth0 were to allow passing an organisation name (instead of the organisation id) to /authorize but that’s not something that’s possible as of right now.
  • We still show the organisation prompt to users that are trying to access the application via the main domain (so without any subdomain).

In our case, we are using the Auth0 SDK for Next.js which made this behavior slightly more complicated to implement (due to some state checks on the callback page). A potential solution to this issue is described here: handleCallback and organizations using multiple (sub)domains · Issue #398 · auth0/nextjs-auth0 · GitHub

1 Like

Thats awesome. Thanks for your reply.

Our application also front end react application, we are using auth0 providers and hooks.
Now i am confident I can go with the solution.

Cheers
Kishore

1 Like

Teamwork makes the dreamwork!