The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
add httpExceptionHandlerService to oauthfilter (#9518)
Weiko524962a3d8f0
diff --git a/packages/twenty-server/src/engine/core-modules/auth/controllers/google-auth.controller.ts b/packages/twenty-server/src/engine/core-modules/auth/controllers/google-auth.controller.tsindex 31b83489f46..ebe6efef876 100644--- a/packages/twenty-server/src/engine/core-modules/auth/controllers/google-auth.controller.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/controllers/google-auth.controller.ts@@ -11,7 +11,10 @@ import { InjectRepository } from '@nestjs/typeorm';import { Response } from 'express';import { Repository } from 'typeorm';-import { AuthException } from 'src/engine/core-modules/auth/auth.exception';+import {+ AuthException,+ AuthExceptionCode,+} from 'src/engine/core-modules/auth/auth.exception';import { AuthOAuthExceptionFilter } from 'src/engine/core-modules/auth/filters/auth-oauth-exception.filter';import { AuthRestApiExceptionFilter } from 'src/engine/core-modules/auth/filters/auth-rest-api-exception.filter';import { GoogleOauthGuard } from 'src/engine/core-modules/auth/guards/google-oauth.guard';@@ -121,7 +124,7 @@ export class GoogleAuthController {}),);}- throw err;+ throw new AuthException(AuthExceptionCode.INTERNAL_SERVER_ERROR, err);}}}diff --git a/packages/twenty-server/src/engine/core-modules/auth/filters/auth-oauth-exception.filter.ts b/packages/twenty-server/src/engine/core-modules/auth/filters/auth-oauth-exception.filter.tsindex 24ac236a2d9..8adf8548181 100644--- a/packages/twenty-server/src/engine/core-modules/auth/filters/auth-oauth-exception.filter.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/filters/auth-oauth-exception.filter.ts@@ -1,9 +1,4 @@-import {- ArgumentsHost,- Catch,- ExceptionFilter,- InternalServerErrorException,-} from '@nestjs/common';+import { ArgumentsHost, Catch, ExceptionFilter } from '@nestjs/common';import { Response } from 'express';@@ -12,10 +7,14 @@ import {AuthExceptionCode,} from 'src/engine/core-modules/auth/auth.exception';import { DomainManagerService } from 'src/engine/core-modules/domain-manager/service/domain-manager.service';+import { HttpExceptionHandlerService } from 'src/engine/core-modules/exception-handler/http-exception-handler.service';@Catch(AuthException)export class AuthOAuthExceptionFilter implements ExceptionFilter {- constructor(private readonly domainManagerService: DomainManagerService) {}+ constructor(+ private readonly domainManagerService: DomainManagerService,+ private readonly httpExceptionHandlerService: HttpExceptionHandlerService,+ ) {}catch(exception: AuthException, host: ArgumentsHost) {const ctx = host.switchToHttp();@@ -28,7 +27,11 @@ export class AuthOAuthExceptionFilter implements ExceptionFilter {.redirect(this.domainManagerService.getBaseUrl().toString());break;default:- throw new InternalServerErrorException(exception.message);+ return this.httpExceptionHandlerService.handleError(+ exception,+ response,+ 500,+ );}}}