Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix(auth): update provider id on sign in

Carl-Gerhard Lindesvärdeb2abd602765
diff --git a/apps/api/src/controllers/oauth-callback.controller.tsx b/apps/api/src/controllers/oauth-callback.controller.tsx
index a2f2e1ce5..76086da45 100644
--- a/apps/api/src/controllers/oauth-callback.controller.tsx
+++ b/apps/api/src/controllers/oauth-callback.controller.tsx
@@ -169,6 +169,15 @@ export async function githubCallback(
},
},
});
+ } else if (existingUser.provider === 'github') {
+ await db.account.update({
+ where: {
+ id: existingUser.id,
+ },
+ data: {
+ providerId: String(githubUserId),
+ },
+ });
}
setSessionTokenCookie(
@@ -371,6 +380,15 @@ export async function googleCallback(
},
},
});
+ } else if (existingAccount.provider === 'google') {
+ await db.account.update({
+ where: {
+ id: existingAccount.id,
+ },
+ data: {
+ providerId: googleId,
+ },
+ });
}
setSessionTokenCookie(