The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Remove demo guard for mail api (#4527)
Thomas Trompette411aac5efcfc
diff --git a/packages/twenty-server/src/engine/modules/auth/controllers/google-apis-auth.controller.ts b/packages/twenty-server/src/engine/modules/auth/controllers/google-apis-auth.controller.tsindex 1001cb07301..7cdb6279e81 100644--- a/packages/twenty-server/src/engine/modules/auth/controllers/google-apis-auth.controller.ts+++ b/packages/twenty-server/src/engine/modules/auth/controllers/google-apis-auth.controller.ts@@ -8,7 +8,6 @@ import { GoogleAPIsRequest } from 'src/engine/modules/auth/strategies/google-apiimport { GoogleAPIsService } from 'src/engine/modules/auth/services/google-apis.service';import { TokenService } from 'src/engine/modules/auth/services/token.service';import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';-import { DemoEnvGuard } from 'src/engine/guards/demo.env.guard';@Controller('auth/google-apis')export class GoogleAPIsAuthController {@@ -26,7 +25,7 @@ export class GoogleAPIsAuthController {}@Get('get-access-token')- @UseGuards(GoogleAPIsProviderEnabledGuard, GoogleAPIsOauthGuard, DemoEnvGuard)+ @UseGuards(GoogleAPIsProviderEnabledGuard, GoogleAPIsOauthGuard)async googleAuthGetAccessToken(@Req() req: GoogleAPIsRequest,@Res() res: Response,@@ -38,6 +37,12 @@ export class GoogleAPIsAuthController {const { workspaceMemberId, workspaceId } =await this.tokenService.verifyTransientToken(transientToken);+ const demoWorkspaceIds = this.environmentService.get('DEMO_WORKSPACE_IDS');++ if (demoWorkspaceIds.includes(workspaceId)) {+ throw new Error('Cannot connect Google account to demo workspace');+ }+if (!workspaceId) {throw new Error('Workspace not found');}diff --git a/packages/twenty-server/src/engine/modules/auth/controllers/google-gmail-auth.controller.ts b/packages/twenty-server/src/engine/modules/auth/controllers/google-gmail-auth.controller.tsindex 96262fe243b..a5cc294aa20 100644--- a/packages/twenty-server/src/engine/modules/auth/controllers/google-gmail-auth.controller.ts+++ b/packages/twenty-server/src/engine/modules/auth/controllers/google-gmail-auth.controller.ts@@ -2,7 +2,6 @@ import { Controller, Get, Req, Res, UseGuards } from '@nestjs/common';import { Response } from 'express';-import { DemoEnvGuard } from 'src/engine/guards/demo.env.guard';import { GoogleAPIsOauthGuard } from 'src/engine/modules/auth/guards/google-apis-oauth.guard';import { GoogleAPIsProviderEnabledGuard } from 'src/engine/modules/auth/guards/google-apis-provider-enabled.guard';import { GoogleAPIsService } from 'src/engine/modules/auth/services/google-apis.service';@@ -26,7 +25,7 @@ export class GoogleGmailAuthController {}@Get('get-access-token')- @UseGuards(GoogleAPIsProviderEnabledGuard, GoogleAPIsOauthGuard, DemoEnvGuard)+ @UseGuards(GoogleAPIsProviderEnabledGuard, GoogleAPIsOauthGuard)async googleAuthGetAccessToken(@Req() req: GoogleAPIsRequest,@Res() res: Response,@@ -38,6 +37,12 @@ export class GoogleGmailAuthController {const { workspaceMemberId, workspaceId } =await this.tokenService.verifyTransientToken(transientToken);+ const demoWorkspaceIds = this.environmentService.get('DEMO_WORKSPACE_IDS');++ if (demoWorkspaceIds.includes(workspaceId)) {+ throw new Error('Cannot connect Gmail account to demo workspace');+ }+if (!workspaceId) {throw new Error('Workspace not found');}