From 90f3a49046f2fc653b8ec9a882cc26ca400dc792 Mon Sep 17 00:00:00 2001 From: gustrb Date: Mon, 21 Oct 2024 17:25:40 -0300 Subject: [PATCH] chore: use the default scope the same way --- .../cloud/server/functions/getWorkspaceAccessToken.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts b/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts index a85b845382d0..d281121a7de9 100644 --- a/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts +++ b/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts @@ -28,17 +28,19 @@ export async function getWorkspaceAccessToken(forceNew = false, scope = '', save // Note: If no scope is given, it means we should assume the default scope, we store the default scopes // in the global variable workspaceScopes. - const scopes = scope === '' ? workspaceScopes.join(' ') : scope; + if (scope === '') { + scope = workspaceScopes.join(' '); + } - const workspaceCredentials = await WorkspaceCredentials.getCredentialByScope(scopes); + const workspaceCredentials = await WorkspaceCredentials.getCredentialByScope(scope); if (workspaceCredentials && !hasWorkspaceAccessTokenExpired(workspaceCredentials) && !forceNew) { SystemLogger.debug( - `Workspace credentials cache hit using scopes: ${scopes}. Avoiding generating a new access token from cloud services.`, + `Workspace credentials cache hit using scope: ${scope}. Avoiding generating a new access token from cloud services.`, ); return workspaceCredentials.accessToken; } - SystemLogger.debug(`Workspace credentials cache miss using scopes: ${scopes}, fetching new access token from cloud services.`); + SystemLogger.debug(`Workspace credentials cache miss using scope: ${scope}, fetching new access token from cloud services.`); const accessToken = await getWorkspaceAccessTokenWithScope(scope, throwOnError);