From 73aa01c5684ecacc38ec774f2c65d4f69f719afb Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Sat, 3 Jun 2023 12:20:04 -0700 Subject: [PATCH] prevent passport init when envs are undefined --- backend/src/utils/setup/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/src/utils/setup/index.ts b/backend/src/utils/setup/index.ts index e0d035a98..ba6c4b618 100644 --- a/backend/src/utils/setup/index.ts +++ b/backend/src/utils/setup/index.ts @@ -20,7 +20,9 @@ import { import { getNodeEnv, getMongoURL, - getSentryDSN + getSentryDSN, + getClientSecretGoogle, + getClientIdGoogle } from '../../config'; import { initializePassport } from '../auth'; @@ -46,7 +48,13 @@ export const setup = async () => { // initializing the database connection await DatabaseService.initDatabase(await getMongoURL()); - await initializePassport(); + + const googleClientSecret: string = await getClientSecretGoogle(); + const googleClientId: string = await getClientIdGoogle(); + + if (googleClientId && googleClientSecret) { + await initializePassport(); + } /** * NOTE: the order in this setup function is critical.