From 9c2e53f344d9752201065b0baceba27e74c258f3 Mon Sep 17 00:00:00 2001 From: Jared Snider Date: Mon, 7 Aug 2023 20:12:08 -0400 Subject: [PATCH 1/2] PM-3331 - TDE - Firefox - Browser extension - fix access denied error on popup load which was caused by the canAccessFeature guard failing to lookup the TDE feature flag as the server config was returning null even after a successful server call as only returned the value if the user was unauthenticated for some reason --- libs/common/src/platform/services/config/config.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/common/src/platform/services/config/config.service.ts b/libs/common/src/platform/services/config/config.service.ts index 54ece293a01b..3a0282035591 100644 --- a/libs/common/src/platform/services/config/config.service.ts +++ b/libs/common/src/platform/services/config/config.service.ts @@ -40,7 +40,12 @@ export class ConfigService implements ConfigServiceAbstraction { const data = new ServerConfigData(response); const serverConfig = new ServerConfig(data); this._serverConfig.next(serverConfig); - if ((await this.authService.getAuthStatus()) === AuthenticationStatus.LoggedOut) { + + const userAuthStatus = await this.authService.getAuthStatus(); + if ( + userAuthStatus === AuthenticationStatus.LoggedOut || + userAuthStatus === AuthenticationStatus.Locked + ) { return serverConfig; } await this.stateService.setServerConfig(data); From 926438be6c9e789e59cfdbaa6333b622e0c9b911 Mon Sep 17 00:00:00 2001 From: Jared Snider Date: Mon, 7 Aug 2023 20:31:47 -0400 Subject: [PATCH 2/2] PM-3331 - After discussion with Andre, further refactor ConfigService logic to always return the latest information from the server so that requests for feature flag data will always get the most up to date information. --- .../platform/services/config/config.service.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libs/common/src/platform/services/config/config.service.ts b/libs/common/src/platform/services/config/config.service.ts index 3a0282035591..7918eb18539f 100644 --- a/libs/common/src/platform/services/config/config.service.ts +++ b/libs/common/src/platform/services/config/config.service.ts @@ -42,14 +42,21 @@ export class ConfigService implements ConfigServiceAbstraction { this._serverConfig.next(serverConfig); const userAuthStatus = await this.authService.getAuthStatus(); - if ( - userAuthStatus === AuthenticationStatus.LoggedOut || - userAuthStatus === AuthenticationStatus.Locked - ) { + if (userAuthStatus === AuthenticationStatus.LoggedOut) { + // if user is unauthenticated, then we can't set server config below + // as it is saved on an active account and there isn't one when + // the user is logged out return serverConfig; } + await this.stateService.setServerConfig(data); this.environmentService.setCloudWebVaultUrl(data.environment?.cloudRegion); + + // Always return new server config from server to calling method + // to ensure up to date information + // This change is specifically for the getFeatureFlag > buildServerConfig flow + // for locked or logged in users. + return serverConfig; } } catch { return null;