-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Auth0] OAuthAccountNotLinked: Another account already exists with the same e-mail address #9992
Comments
Same issue here with Github & Google provider. If I delete the session manually from the browser & try to login back, I get the same error: OAuthAccountNotLinked: Another account already exists with the same e-mail address |
Hello, Same issue here on
|
Same issue here with "^5.0.0-beta.9", but "^5.0.0-beta.4" was working. |
I did some quick tests on vercel and versions beta.7 and beta.8 gave the same error as beta.9. The error occurs with the google provider, github one is working. Works fine with beta.5. |
Thanks for your patience everyone, this should be fixed in |
Hi @ndom91, As I sat at my desk I got the email that this was merged, perfect timing. Unfortunately, it looks like I still get the same issue. Please see the attached video. Recording.2024-02-14.144757.mp4I'll run through what I'm doing in the video
This is using the latest beta version Let me know if you need any more information. Edit |
@pippinmole hey thanks for the quick response! So just some quick notes, non-OIDC providers (Like Github) were fixed in So I just double checked with Where it would previously throw the "oauth account already exists" error, I was now able to successfully login. In addition, I couldn't see any of the logging you pointed out with the published It looks like yuo're tryign this with our EDIT: Ah just noticed you posted a link to a repo, let me take a look 👀 |
@pippinmole Just thought of something.. Regarding that database of users in your demo app, when was the Github user created? The one that yuo're trying to login with but triggers the error? Do you happen to remember which version of |
If you're referring to the video in the opening comment, then the versions were as such (from my
If you need the full repro, this is the commit before upgrading to beta 11: https://github.com/pippinmole/auth0-authjs-bug/tree/638200d60c57a6e6ca15168538d1ed73717f97d0 |
@ndom91 So in the first video it shows a bug where you can log in the first time with Auth0, then logging in the second time with the SAME PROVIDER causes that error, and the recent video I sent shows me logging in first time with Auth0, then trying to log in via GitHub (THROUGH AUTH0) and getting the error, because of the same email address conflict Edit |
I think I've confused myself here. Here's a video (doing exactly the same thing as the first video), but it working successfully on the latest version (beta 11): Recording.2024-02-14.152358.mp4So it looks like the original issue is fixed. |
@pippinmole okay I'm pretty sure I know what the issue is.. The root bug in this GH issue should be fixed, howeverrr if you created the users in your DB during The issue boils down to the fact that your The easiest thing to do is to just drop the account + user rows from your DB, next time you login with them they will be recreated with the correct values. However, I know that might not be possible in a production environment. If that's not an option for you, you can manually modify the For Github, yuor So what you want to do is set the Some general notes on your repository:
|
Ah okay, good to hear. Did you create a new DB / users? |
Yes, at the start I ran |
So just to confirm the intended behaviour, if I do the following:
Should it either: |
Yeah so this logging in with one provider and then another provider with the same email is a different topic. You can read more about it here and here (see second item under "Security"). We call it "Account linking". But long story short, you can enable this with the provider config option |
Perfect, thank you for your help with all of this |
Hello, @ndom91 I tried your fix on version 5.0.11 and it solved the problem concerning authentication with Google. (thanks for it) However I don't know if it has anything to do with this update but now the redirect after a connection with credentials doesn't work anymore. It may be my fault for changing the configuration, but here are the logs
|
@jbultez I can't reproduce with Can you provide me some more details about your setup? A reproduction URL from stackblitz.com or similar would be great. |
Hello @ndom91 I've managed to correct my problem, but I still don't understand how this error could occur. I have a server action where I use the next-auth signIn. Here is the code "use server";
import * as z from "zod";
import { userLoginSchema } from "@/schemas/user.schema";
import { signIn } from "@/auth";
import { DEFAULT_LOGIN_REDIRECT } from "@/routes";
import { AuthError } from "next-auth";
export const login = async (values: z.infer<typeof userLoginSchema>) => {
const validateFields = userLoginSchema.safeParse(values);
if (!validateFields.success) {
return { error: "Invalid data provided" };
}
const { email, password } = validateFields.data;
try {
await signIn("credentials", {
email,
password,
redirectTo: DEFAULT_LOGIN_REDIRECT,
});
} catch (error) {
// I see in my server console the error message
console.log(error);
if (error instanceof AuthError) {
switch (error.type) {
case "CredentialsSignin":
return { error: "Invalid email or password" };
default:
return { error: "Something went wrong" };
}
}
// If I let the return error The NEXTREDIRECT error is there
return { error: "Something went wrong" };
// If I put `throw error` the NEXTREDIRECT error is gone and my user is logged in and redirected nicely
// throw error;
}
return { success: "You are now logged in" };
}; If I use |
Problem: NextAuth.js Creates New Accounts on Every Login (GitHub and Google)Root Cause: Missing
|
Provider type
Auth0
Environment
System:
OS: Windows 11 10.0.22631
CPU: (16) x64 AMD Ryzen 7 5700X 8-Core Processor
Memory: 9.76 GB / 31.93 GB
Binaries:
Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.11.0 - C:\Program Files\nodejs\pnpm.CMD
Browsers:
Edge: Chromium (121.0.2277.112)
Internet Explorer: 11.0.22621.1
npmPackages:
@auth/prisma-adapter: ^1.3.3 => 1.3.3
next: latest => 14.1.0
next-auth: beta => 5.0.0-beta.9
react: ^18.2.0 => 18.2.0
Reproduction URL
https://github.com/pippinmole/auth0-authjs-bug
Describe the issue
I haev a default setup with a prisma schema defined here, authjs config defined here,
Please see attached video
Recording.2024-02-11.001449.mp4
As the error message says, I've taken a look at this, and this is what it suggests:
I shouldn't have to enable a dangerous flag just so a user can log in twice
Additional note: Everything works perfectly with the default GitHub provider, so it looks like it's specific to the provider
How to reproduce
Expected behavior
It should let you log in the second time with no issues
The text was updated successfully, but these errors were encountered: