From f84d83429562a705657103a7e5a09a8a1bd12610 Mon Sep 17 00:00:00 2001 From: Chamika J <75464293+chamikaJ@users.noreply.github.com> Date: Mon, 4 Aug 2025 17:02:48 +0530 Subject: [PATCH] feat(auth): add logging for token audience validation in Google authentication - Introduced console logs in the `googleMobileAuth` method to display the token audience, allowed client IDs, and the status of relevant environment variables. - This enhancement aids in debugging and ensures better visibility into the authentication process. --- worklenz-backend/src/controllers/auth-controller.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/worklenz-backend/src/controllers/auth-controller.ts b/worklenz-backend/src/controllers/auth-controller.ts index d1505dc2..da26936a 100644 --- a/worklenz-backend/src/controllers/auth-controller.ts +++ b/worklenz-backend/src/controllers/auth-controller.ts @@ -201,6 +201,13 @@ export default class AuthController extends WorklenzControllerBase { process.env.GOOGLE_IOS_CLIENT_ID, // iOS client ID ].filter(Boolean); // Remove undefined values + console.log("Token audience (aud):", profile.aud); + console.log("Allowed client IDs:", allowedClientIds); + console.log("Environment variables check:"); + console.log("- GOOGLE_CLIENT_ID:", process.env.GOOGLE_CLIENT_ID ? "Set" : "Not set"); + console.log("- GOOGLE_ANDROID_CLIENT_ID:", process.env.GOOGLE_ANDROID_CLIENT_ID ? "Set" : "Not set"); + console.log("- GOOGLE_IOS_CLIENT_ID:", process.env.GOOGLE_IOS_CLIENT_ID ? "Set" : "Not set"); + if (!allowedClientIds.includes(profile.aud)) { return res.status(400).send(new ServerResponse(false, null, "Invalid token audience")); }