Skip to content

The open alternative to Salesforce, designed for AI.

fix: lowercase OAuth handle to prevent duplicate connected accounts (#21120)

neo7731ba7a3fa5451
diff --git a/packages/twenty-server/src/engine/core-modules/auth/controllers/google-apis-auth.controller.ts b/packages/twenty-server/src/engine/core-modules/auth/controllers/google-apis-auth.controller.ts
index a5b1a7a6dfb..853b5ab960f 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/controllers/google-apis-auth.controller.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/controllers/google-apis-auth.controller.ts
@@ -96,7 +96,7 @@ export class GoogleAPIsAuthController {
id: workspaceId,
});
- const handle = emails[0].value;
+ const handle = emails[0].value.toLowerCase();
const connectedAccountId =
await this.googleAPIsService.refreshGoogleRefreshToken({
diff --git a/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-apis-auth.controller.ts b/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-apis-auth.controller.ts
index 55d024d33ed..827666d0dc7 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-apis-auth.controller.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-apis-auth.controller.ts
@@ -103,7 +103,7 @@ export class MicrosoftAPIsAuthController {
);
}
- const handle = emails[0].value;
+ const handle = emails[0].value.toLowerCase();
const connectedAccountId =
await this.microsoftAPIsService.refreshMicrosoftRefreshToken({