mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[PM-22839] Update Device Approvals visibility based on SSO configuration (#16144)
* Add ssoEnabled and ssoMemberDecryptionType properties to ProfileOrganizationResponse * Add SSO support to Organization model with ssoEnabled and ssoMemberDecryptionType properties, and implement related tests * Upsert organization SSO settings in memory after save Updates organization data in memory with new SSO configuration values to ensure immediate UI updates for Device Approvals page visibility. * Refactor SSO component to simplify upsertOrganizationWithSsoChanges method - Updated the method signature to accept a single OrganizationSsoRequest object instead of separate parameters. - Adjusted the internal logic to directly use properties from the OrganizationSsoRequest for updating the organization state. * Specify OrganizationData type for updatedOrganization in SSO component
This commit is contained in:
@@ -16,8 +16,9 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
||||
import {
|
||||
getOrganizationById,
|
||||
OrganizationService,
|
||||
InternalOrganizationServiceAbstraction,
|
||||
} from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { OrganizationData } from "@bitwarden/common/admin-console/models/data/organization.data";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import {
|
||||
@@ -196,7 +197,7 @@ export class SsoComponent implements OnInit, OnDestroy {
|
||||
private apiService: ApiService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService,
|
||||
private organizationService: OrganizationService,
|
||||
private organizationService: InternalOrganizationServiceAbstraction,
|
||||
private accountService: AccountService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction,
|
||||
private toastService: ToastService,
|
||||
@@ -298,6 +299,8 @@ export class SsoComponent implements OnInit, OnDestroy {
|
||||
const response = await this.organizationApiService.updateSso(this.organizationId, request);
|
||||
this.populateForm(response);
|
||||
|
||||
await this.upsertOrganizationWithSsoChanges(request);
|
||||
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
title: null,
|
||||
@@ -399,4 +402,25 @@ export class SsoComponent implements OnInit, OnDestroy {
|
||||
|
||||
document.body.append(div);
|
||||
}
|
||||
|
||||
private async upsertOrganizationWithSsoChanges(
|
||||
organizationSsoRequest: OrganizationSsoRequest,
|
||||
): Promise<void> {
|
||||
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
|
||||
const currentOrganization = await firstValueFrom(
|
||||
this.organizationService
|
||||
.organizations$(userId)
|
||||
.pipe(getOrganizationById(this.organizationId)),
|
||||
);
|
||||
|
||||
if (currentOrganization) {
|
||||
const updatedOrganization: OrganizationData = {
|
||||
...currentOrganization,
|
||||
ssoEnabled: organizationSsoRequest.enabled,
|
||||
ssoMemberDecryptionType: organizationSsoRequest.data.memberDecryptionType,
|
||||
};
|
||||
|
||||
await this.organizationService.upsert(updatedOrganization, userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user