Login Issue: Organization Membership Required

Hi everyone,

I’m facing a login issue with my app and would appreciate your help. The app is set up to allow only invited users who belong to an organization to log in, and the connection is configured for Google.

Currently, when a user who is not part of an organization tries to log in, they receive the error message:

“client requires organization membership, but user does not belong to any organization.”

What I’m trying to achieve is to either show a user-friendly error message or redirect them back to the login page. However, I’ve noticed that the user still gets registered in Auth0, which complicates things.

Has anyone encountered this issue before? Any tips on how to handle the error more gracefully or prevent unauthorized users from being registered would be greatly appreciated!

Thanks in advance!

Hi @geilerhipiamejia0,

Unfortunately, it’s not possible to avoid the user being created when attempting to login with social connections.

One workaround might be to use an Auth0 Action to deny them access using the api.access.deny() method.

Alternatively, you could use the Action to log the user out to clear their session and then redirect them back to the login page.

api.redirect.sendUserTo('https://TENANT_DOMAIN/v2/logout', {
      query: { returnTo: 'WHITELISTED_LOGOUT_URL' }

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.