diff --git a/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.ts b/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.ts index aa84ae4fb9..fead0f07e3 100644 --- a/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.ts +++ b/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.ts @@ -35,6 +35,7 @@ import { Redirect, UnauthorizedException, Req, + HttpException, } from "@nestjs/common"; import { ApiOperation, ApiTags as DocsTags } from "@nestjs/swagger"; import { plainToInstance } from "class-transformer"; @@ -56,7 +57,7 @@ export type OAuthCallbackState = { }) @DocsTags("Conferencing") export class ConferencingController { - private readonly logger = new Logger("Platform Gcal Provider"); + private readonly logger = new Logger("ConferencingController"); constructor( private readonly tokensRepository: TokensRepository, @@ -144,6 +145,10 @@ export class ConferencingController { @Query("error") error: string | undefined, @Query("error_description") error_description: string | undefined ): Promise<{ url: string }> { + if (!state) { + throw new BadRequestException("Missing `state` query param"); + } + const decodedCallbackState: OAuthCallbackState = JSON.parse(state); try { const userId = await this.tokensRepository.getAccessTokenOwnerId(decodedCallbackState.accessToken); @@ -169,6 +174,9 @@ export class ConferencingController { ); } } catch (error) { + if (error instanceof HttpException || error instanceof Error) { + this.logger.error(error.message); + } return { url: decodedCallbackState.onErrorReturnTo ?? "", };