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

defaultProvider in nuxt.config doesn't apply #531

Closed
BerzinsU opened this issue Sep 22, 2023 · 2 comments
Closed

defaultProvider in nuxt.config doesn't apply #531

BerzinsU opened this issue Sep 22, 2023 · 2 comments
Assignees

Comments

@BerzinsU
Copy link

Environment


  • Operating System: Darwin
  • Node Version: v18.17.0
  • Nuxt Version: 3.6.5
  • Nitro Version: 2.5.2
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: devtools, auth, app, components, modules, i18n, vite, ui, googleFonts, colorMode
  • Runtime Modules: @nuxtjs/eslint-module@4.1.0, @nuxtjs/i18n@8.0.0-rc.2, @sidebase/nuxt-auth@0.6.0-beta.5, @nuxt/content@2.7.2, nuxt-viewport@2.0.6, @nuxthq/ui@2.7.0, nuxt-icon@0.5.0, @nuxtjs/google-fonts@3.0.2, @pinia/nuxt@0.4.11
  • Build Modules: -

Reproduction

No response

Describe the bug

nuxt.config
Set globalAppMiddleware to true, and defaultProvider to any configured provider.
When redirected to login, you are given the provider choice page not the providers' login page.

If globalAppMiddleware is set to false and await signIn("github") is explicitly used, it does open GitHubs OAuth flow immediately.

Another issue is that not every configured provider is selected like this. If await signIn("auth0") is used, then
Try signing in with a different account. error is shown on provider select. But clicking it there, does work. Maybe separate bug.

Additional context

No response

Logs

No response

@zoey-kaiser
Copy link
Member

Hi @BerzinsU 👋

Set globalAppMiddleware to true, and defaultProvider to any configured provider.
When redirected to login, you are given the provider choice page not the providers' login page.

I sadly was not able to reproduce this issue. In the video below you can see I have globalmiddleware enabled and the default provider of github set. When clicking on signin, it takes me directly to the github signin page (even though the button click did not define which provider should be used to login). The same thing also happened when going to a page, that was globally (or locally) protected. I was directly forwarded to the github signin page.

Screen.Recording.2023-10-11.at.18.54.02.mov

Another issue is that not every configured provider is selected like this. If await signIn("auth0") is used, then
Try signing in with a different account. error is shown on provider select. But clicking it there, does work. Maybe separate bug.

I setup some demo data for an Auth0 provider and this worked as well.

Screen.Recording.2023-10-11.at.19.03.23.mov

I will close this issue, as the bug seemed to have been resolved since version 0.6.0-beta.2. Feel free to test it out again and let me know, otherwise we can reopen this issue and investigate your problem further!

@abn
Copy link

abn commented Mar 28, 2024

Another issue is that not every configured provider is selected like this. If await signIn("auth0") is used, then
Try signing in with a different account. error is shown on provider select. But clicking it there, does work. Maybe separate bug.

@zoey-kaiser the issue with auth0 seems to be slightly different in that it occurs after the callback is hit. We end up seeing https://next-auth.js.org/errors#oauth_callback_error.

 ERROR  [next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error State cookie was missing. { error:
   { TypeError: State cookie was missing.
       at Object.use (/path/to/projectnode_modules/.pnpm/next-auth@4.21.1_next@13.5.6_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/lib/oauth/checks.js:103:23)
       at oAuthCallback (/path/to/projectnode_modules/.pnpm/next-auth@4.21.1_next@13.5.6_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/lib/oauth/callback.js:89:25)
       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
       at async Object.callback (/path/to/projectnode_modules/.pnpm/next-auth@4.21.1_next@13.5.6_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/routes/callback.js:52:11)
       at async AuthHandler (/path/to/projectnode_modules/.pnpm/next-auth@4.21.1_next@13.5.6_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/index.js:201:28)
       at Object.handler (/path/to/projectnode_modules/.pnpm/@sidebase+nuxt-auth@0.7.0_next-auth@4.21.1/node_modules/@sidebase/nuxt-auth/dist/runtime/server/services/authjs/nuxtAuthHandler.mjs:88:24)
       at async file:///path/to/projectnode_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:1962:19
       at async Object.callAsync (file:///path/to/projectnode_modules/.pnpm/unctx@2.3.1/node_modules/unctx/dist/index.mjs:72:16)
       at async Server.toNodeHandle (file:///path/to/projectnode_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:2249:7)
     name: 'OAuthCallbackError',
     code: undefined },
  providerId: 'auth0',
  message: 'State cookie was missing.' }

A following sign-in attempt using the button then works. The issue occurs when the globally protected page is hit directly. We are on 0.7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants