From 806bd8d03956e49c628334e33804422f9fee93c1 Mon Sep 17 00:00:00 2001 From: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com> Date: Wed, 7 Jun 2023 17:47:30 -0400 Subject: [PATCH] Tech-Debt - [PM-2283] - Update ConfigApiService getServerConfig call to send access token if it exists (#5464) * PM-2283 - Update config api service get server config call to send authed when we have an access token so that LaunchDarkly on the server can properly acquire user context. * PM-2283- Replace token service with Auth service per PR feedback * PM-2283 - Refactor config api service get authed status based on PR feedback. * PM-2283 - Fix import issues due to platform folder creation and file moves --- libs/angular/src/services/jslib-services.module.ts | 2 +- .../platform/services/config/config-api.service.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/angular/src/services/jslib-services.module.ts b/libs/angular/src/services/jslib-services.module.ts index a170389efb..9862ca90e8 100644 --- a/libs/angular/src/services/jslib-services.module.ts +++ b/libs/angular/src/services/jslib-services.module.ts @@ -631,7 +631,7 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction"; { provide: ConfigApiServiceAbstraction, useClass: ConfigApiService, - deps: [ApiServiceAbstraction], + deps: [ApiServiceAbstraction, AuthServiceAbstraction], }, { provide: AnonymousHubServiceAbstraction, diff --git a/libs/common/src/platform/services/config/config-api.service.ts b/libs/common/src/platform/services/config/config-api.service.ts index 087b609493..b874dbfd99 100644 --- a/libs/common/src/platform/services/config/config-api.service.ts +++ b/libs/common/src/platform/services/config/config-api.service.ts @@ -1,12 +1,17 @@ import { ApiService } from "../../../abstractions/api.service"; -import { ConfigApiServiceAbstraction as ConfigApiServiceAbstraction } from "../../abstractions/config/config-api.service.abstraction"; +import { AuthService } from "../../../auth/abstractions/auth.service"; +import { AuthenticationStatus } from "../../../auth/enums/authentication-status"; +import { ConfigApiServiceAbstraction } from "../../abstractions/config/config-api.service.abstraction"; import { ServerConfigResponse } from "../../models/response/server-config.response"; export class ConfigApiService implements ConfigApiServiceAbstraction { - constructor(private apiService: ApiService) {} + constructor(private apiService: ApiService, private authService: AuthService) {} async get(): Promise { - const r = await this.apiService.send("GET", "/config", null, false, true); + const authed: boolean = + (await this.authService.getAuthStatus()) !== AuthenticationStatus.LoggedOut; + + const r = await this.apiService.send("GET", "/config", null, authed, true); return new ServerConfigResponse(r); } }