T
Typebot•3mo ago
zEveery

Gitlab OAuth Error

Hello! After upgrading to 3.8.0 we're facing a issue with gitlab oauth. When I try to log in, I receive: [31m[auth][error] OAuthAccountNotLinked: Another account already exists with the same e-mail address. Read more at https://errors.authjs.dev#oauthaccountnotlinked The thing is, I dont have any other linked email (its a sign in, not a sign up). I got few data: (Screenshot 1)
-- Show oAuth
select * from "Account" a ;
-- Show oAuth
select * from "Account" a ;
(Screenshot 2)
select * from "User" u ;
select * from "User" u ;
(Screenshot 3)
select a."userId", u."name", u.email, "providerAccountId" from "Account" a
join "User" u
on a."userId" = u.id
select a."userId", u."name", u.email, "providerAccountId" from "Account" a
join "User" u
on a."userId" = u.id
Complete log error:
[auth][error] OAuthAccountNotLinked: Another account already exists with the same e-mail address. Read more at https://errors.authjs.dev#oauthaccountnotlinked
at nR (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:3050)
at async c4 (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:42856)
at async la (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:54302)
at async lr (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:59016)
at async tf.do (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:18835)
at async tf.handle (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:23727)
at async doRender (/app/node_modules/next/dist/server/base-server.js:1513:42)
at async NextNodeServer.renderToResponseWithComponentsImpl (/app/node_modules/next/dist/server/base-server.js:1915:28)
at async NextNodeServer.renderPageComponent (/app/node_modules/next/dist/server/base-server.js:2403:24)
at async NextNodeServer.renderToResponseImpl (/app/node_modules/next/dist/server/base-server.js:2440:32)
[auth][error] OAuthAccountNotLinked: Another account already exists with the same e-mail address. Read more at https://errors.authjs.dev#oauthaccountnotlinked
at nR (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:3050)
at async c4 (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:42856)
at async la (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:54302)
at async lr (/app/apps/builder/.next/server/app/api/auth/[...nextauth]/route.js:692:59016)
at async tf.do (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:18835)
at async tf.handle (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:18:23727)
at async doRender (/app/node_modules/next/dist/server/base-server.js:1513:42)
at async NextNodeServer.renderToResponseWithComponentsImpl (/app/node_modules/next/dist/server/base-server.js:1915:28)
at async NextNodeServer.renderPageComponent (/app/node_modules/next/dist/server/base-server.js:2403:24)
at async NextNodeServer.renderToResponseImpl (/app/node_modules/next/dist/server/base-server.js:2440:32)
Thanks in advance.
No description
No description
No description
3 Replies
zEveery
zEveeryOP•3mo ago
Found the culprit! The issue is: next-auth in v5.0.0-beta.28 changed how gitlab auth should work. Its now using profile.sub (Reference: https://github.com/nextauthjs/next-auth/commit/2da115c6649e1d98aee33b364efa2c412608898b) Before it was profile.id, they even had a discussion about it. Reference: https://github.com/nextauthjs/next-auth/pull/11176 sub is for oidc ONLY, not for oauth. Thats way this code can break authentications. The resolution for now is simples, we can just inject the method on gitlabProvider. See Attachment 1. Did few tests and that worked as expected! I'll send an PR with this.
No description
zEveery
zEveeryOP•3mo ago
GitHub
fix(gitlab-auth): patch profile parsing for next-auth@v5 compatibil...
🚑 fix(gitlab-auth): patch profile parsing for next-auth@v5 compatibility Description Fixes a compatibility issue with GitLab authentication after upgrading to next-auth@v5.0.0-beta.28. Starting fro...
Baptiste
Baptiste•3mo ago
Appreciate the contribution 🙂

Did you find this page helpful?