From 5c7121d881ac067b5b921ab4149c3eb34954eca1 Mon Sep 17 00:00:00 2001 From: Alex Morask <144709477+amorask-bitwarden@users.noreply.github.com> Date: Wed, 1 Nov 2023 10:50:31 -0400 Subject: [PATCH] [AC-1593] Update Toast/refresh token when User adds SM to org (#6610) * Update toast message for SM addition * Refresh identity token after SM sub * Thomas' feedback --- .../sm-subscribe-standalone.component.ts | 14 +++++++++++++- apps/web/src/locales/en/messages.json | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/billing/organizations/sm-subscribe-standalone.component.ts b/apps/web/src/app/billing/organizations/sm-subscribe-standalone.component.ts index ebde4ab253..521600163f 100644 --- a/apps/web/src/app/billing/organizations/sm-subscribe-standalone.component.ts +++ b/apps/web/src/app/billing/organizations/sm-subscribe-standalone.component.ts @@ -1,6 +1,7 @@ import { Component, EventEmitter, Input, Output } from "@angular/core"; import { FormBuilder } from "@angular/forms"; +import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction"; import { InternalOrganizationServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationData } from "@bitwarden/common/admin-console/models/data/organization.data"; @@ -26,6 +27,7 @@ export class SecretsManagerSubscribeStandaloneComponent { formGroup = secretsManagerSubscribeFormFactory(this.formBuilder); constructor( + private apiService: ApiService, private formBuilder: FormBuilder, private platformUtilsService: PlatformUtilsService, private i18nService: I18nService, @@ -52,7 +54,17 @@ export class SecretsManagerSubscribeStandaloneComponent { }); await this.organizationService.upsert(organizationData); - this.platformUtilsService.showToast("success", null, this.i18nService.t("subscriptionUpdated")); + /* + Because subscribing to Secrets Manager automatically provides access to Secrets Manager for the + subscribing user, we need to refresh the identity token to account for their updated permissions. + */ + await this.apiService.refreshIdentityToken(); + + this.platformUtilsService.showToast( + "success", + null, + this.i18nService.t("subscribedToSecretsManager") + ); this.onSubscribe.emit(); }; diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 9caf99e796..3f44be2376 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -3464,6 +3464,9 @@ "subscriptionUpdated": { "message": "Subscription updated" }, + "subscribedToSecretsManager": { + "message": "Subscription updated. You now have access to Secrets Manager." + }, "additionalOptions": { "message": "Additional options" },