Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple signIn endpoints for local provider #976

Open
2 of 5 tasks
despatates opened this issue Jan 7, 2025 · 0 comments
Open
2 of 5 tasks

Multiple signIn endpoints for local provider #976

despatates opened this issue Jan 7, 2025 · 0 comments
Labels
enhancement An improvement that needs to be added pending An issue waiting for triage

Comments

@despatates
Copy link
Contributor

despatates commented Jan 7, 2025

Describe the feature

It could be nice to have many auth configs or providers. Currently, we can only have one setup.

My application uses the local provider with an external API.
Depending on the business workflow, I must use different endpoints to authenticate the user. Once authenticated, the tokens are the same as well as the refresh logic, no matter the endpoint used.

I can't override the endpoint settings when calling the signIn() method.
I'm currently overriding the configuration on demand (not clean but it works).

let initialSignIn
const config = useRuntimeConfig()
const { signIn } = useAuth()

try {
  // [...]
  initialSignIn = { ...config.public.auth.provider.endpoints.signIn }
  config.public.auth.provider.endpoints.signIn = {
    path: '/other/endpoint/path',
    method: 'post',
  }

  await signIn(
    {
      /* payload for the use case */
    },
    { callbackUrl: '/' },
  )
} catch (error) {
  // [...]
} finally {
  // revert the initial settings
  if (initialSignIn) {
    config.public.auth.provider.endpoints.signIn = initialSignIn
  }
}

Maybe there is a clean way to do it? If so, let me know.

How would you implement this?

The short way: Be able to override the settings set in the nuxt.config.ts file when calling signIn().

The long way: Be able to define many configs or providers in the nuxt.config.ts file.
In the nuxt v2 plugin, I used several strategies with local scheme, and it was perfectly matching my use case.

Additional information

  • Would you be willing to help implement this feature?

Provider

  • AuthJS
  • Local
  • Refresh
  • New Provider
@despatates despatates added enhancement An improvement that needs to be added pending An issue waiting for triage labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement that needs to be added pending An issue waiting for triage
Projects
None yet
Development

No branches or pull requests

1 participant