Skip to content

Scheduling infrastructure for absolutely everyone.

Allow account linking for Google and SAML providers (#6874)

Deepak Prabhakara1ee3783db30f
diff --git a/apps/web/pages/api/auth/[...nextauth].tsx b/apps/web/pages/api/auth/[...nextauth].tsx
index ce594147631..54976e82025 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 61b540ec0a4..a838f0d47d5 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 }],
},
],
},