diff --git a/apps/web/pages/api/auth/[...nextauth].tsx b/apps/web/pages/api/auth/[...nextauth].tsx index ce59414763..54976e8202 100644 --- a/apps/web/pages/api/auth/[...nextauth].tsx +++ b/apps/web/pages/api/auth/[...nextauth].tsx @@ -164,6 +164,7 @@ if (IS_GOOGLE_LOGIN_ENABLED) { GoogleProvider({ clientId: GOOGLE_CLIENT_ID, clientSecret: GOOGLE_CLIENT_SECRET, + allowDangerousEmailAccountLinking: true, }) ); } @@ -202,6 +203,7 @@ if (isSAMLLoginEnabled) { clientId: "dummy", clientSecret: "dummy", }, + allowDangerousEmailAccountLinking: true, }); } @@ -497,7 +499,13 @@ export default NextAuth({ return true; } - if (existingUserWithEmail.identityProvider === IdentityProvider.CAL) { + // User signs up with email/password and then tries to login with Google/SAML using the same email + if ( + existingUserWithEmail.identityProvider === IdentityProvider.CAL && + (idP === IdentityProvider.GOOGLE || idP === IdentityProvider.SAML) + ) { + return true; + } else if (existingUserWithEmail.identityProvider === IdentityProvider.CAL) { return "/auth/error?error=use-password-login"; } diff --git a/apps/web/pages/api/auth/signup.ts b/apps/web/pages/api/auth/signup.ts index 61b540ec0a..a838f0d47d 100644 --- a/apps/web/pages/api/auth/signup.ts +++ b/apps/web/pages/api/auth/signup.ts @@ -43,7 +43,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) OR: [ { username }, { - AND: [{ email: userEmail }, { password: { not: null } }, { username: { not: null } }], + AND: [{ email: userEmail }], }, ], },