mirror of
https://github.com/bitwarden/browser
synced 2026-03-02 11:31:44 +00:00
Added encrypted default collection name to new feature flagged restore user methods/endpoint.
This commit is contained in:
@@ -1,10 +1,20 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { Component, Inject } from "@angular/core";
|
||||
import { combineLatest, firstValueFrom, from, Observable, switchMap } from "rxjs";
|
||||
|
||||
import { OrganizationUserApiService } from "@bitwarden/admin-console/common";
|
||||
import {
|
||||
OrganizationUserApiService,
|
||||
OrganizationUserService,
|
||||
} from "@bitwarden/admin-console/common";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { OrganizationUserStatusType } from "@bitwarden/common/admin-console/enums";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { getById } from "@bitwarden/common/platform/misc";
|
||||
import { DIALOG_DATA, DialogService } from "@bitwarden/components";
|
||||
|
||||
import { BulkUserDetails } from "./bulk-status.component";
|
||||
@@ -34,10 +44,15 @@ export class BulkRestoreRevokeComponent {
|
||||
error: string;
|
||||
showNoMasterPasswordWarning = false;
|
||||
nonCompliantMembers: boolean = false;
|
||||
organization$: Observable<Organization>;
|
||||
|
||||
constructor(
|
||||
protected i18nService: I18nService,
|
||||
private organizationUserApiService: OrganizationUserApiService,
|
||||
private organizationUserService: OrganizationUserService,
|
||||
private accountService: AccountService,
|
||||
private organizationService: OrganizationService,
|
||||
private configService: ConfigService,
|
||||
@Inject(DIALOG_DATA) protected data: BulkRestoreDialogParams,
|
||||
) {
|
||||
this.isRevoking = data.isRevoking;
|
||||
@@ -46,6 +61,12 @@ export class BulkRestoreRevokeComponent {
|
||||
this.showNoMasterPasswordWarning = this.users.some(
|
||||
(u) => u.status > OrganizationUserStatusType.Invited && u.hasMasterPassword === false,
|
||||
);
|
||||
|
||||
this.organization$ = accountService.activeAccount$.pipe(
|
||||
switchMap((account) =>
|
||||
organizationService.organizations$(account?.id).pipe(getById(this.organizationId)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
get bulkTitle() {
|
||||
@@ -83,9 +104,24 @@ export class BulkRestoreRevokeComponent {
|
||||
userIds,
|
||||
);
|
||||
} else {
|
||||
return await this.organizationUserApiService.restoreManyOrganizationUsers(
|
||||
this.organizationId,
|
||||
userIds,
|
||||
return await firstValueFrom(
|
||||
combineLatest([
|
||||
this.configService.getFeatureFlag$(FeatureFlag.DefaultUserCollectionRestore),
|
||||
this.organization$,
|
||||
]).pipe(
|
||||
switchMap(([enabled, organization]) => {
|
||||
if (enabled) {
|
||||
return this.organizationUserService.bulkRestoreUsers(organization, userIds);
|
||||
} else {
|
||||
return from(
|
||||
this.organizationUserApiService.restoreManyOrganizationUsers(
|
||||
this.organizationId,
|
||||
userIds,
|
||||
),
|
||||
);
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { FormBuilder, Validators } from "@angular/forms";
|
||||
import {
|
||||
combineLatest,
|
||||
firstValueFrom,
|
||||
from,
|
||||
map,
|
||||
Observable,
|
||||
of,
|
||||
@@ -17,6 +18,7 @@ import {
|
||||
import {
|
||||
CollectionAdminService,
|
||||
OrganizationUserApiService,
|
||||
OrganizationUserService,
|
||||
} from "@bitwarden/admin-console/common";
|
||||
import {
|
||||
getOrganizationById,
|
||||
@@ -36,6 +38,7 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { ProductTierType } from "@bitwarden/common/billing/enums";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import {
|
||||
@@ -197,6 +200,7 @@ export class MemberDialogComponent implements OnDestroy {
|
||||
private toastService: ToastService,
|
||||
private configService: ConfigService,
|
||||
private deleteManagedMemberWarningService: DeleteManagedMemberWarningService,
|
||||
private organizationUserService: OrganizationUserService,
|
||||
) {
|
||||
this.organization$ = accountService.activeAccount$.pipe(
|
||||
switchMap((account) =>
|
||||
@@ -633,9 +637,28 @@ export class MemberDialogComponent implements OnDestroy {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.organizationUserApiService.restoreOrganizationUser(
|
||||
this.params.organizationId,
|
||||
this.params.organizationUserId,
|
||||
await firstValueFrom(
|
||||
combineLatest([
|
||||
this.configService.getFeatureFlag$(FeatureFlag.DefaultUserCollectionRestore),
|
||||
this.organization$,
|
||||
this.editParams$,
|
||||
]).pipe(
|
||||
switchMap(([enabled, organization, params]) => {
|
||||
if (enabled) {
|
||||
return this.organizationUserService.restoreUser(
|
||||
organization,
|
||||
params.organizationUserId,
|
||||
);
|
||||
} else {
|
||||
return from(
|
||||
this.organizationUserApiService.restoreOrganizationUser(
|
||||
params.organizationId,
|
||||
params.organizationUserId,
|
||||
),
|
||||
);
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
this.toastService.showToast({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { inject, Injectable, signal } from "@angular/core";
|
||||
import { lastValueFrom, firstValueFrom } from "rxjs";
|
||||
import { lastValueFrom, firstValueFrom, from, switchMap } from "rxjs";
|
||||
|
||||
import {
|
||||
OrganizationUserApiService,
|
||||
@@ -10,8 +10,8 @@ import { UserNamePipe } from "@bitwarden/angular/pipes/user-name.pipe";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { OrganizationManagementPreferencesService } from "@bitwarden/common/admin-console/abstractions/organization-management-preferences/organization-management-preferences.service";
|
||||
import {
|
||||
OrganizationUserType,
|
||||
OrganizationUserStatusType,
|
||||
OrganizationUserType,
|
||||
} from "@bitwarden/common/admin-console/enums";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { assertNonNullish } from "@bitwarden/common/auth/utils";
|
||||
@@ -119,7 +119,20 @@ export class MemberActionsService {
|
||||
async restoreUser(organization: Organization, userId: string): Promise<MemberActionResult> {
|
||||
this.startProcessing();
|
||||
try {
|
||||
await this.organizationUserApiService.restoreOrganizationUser(organization.id, userId);
|
||||
await firstValueFrom(
|
||||
this.configService.getFeatureFlag$(FeatureFlag.DefaultUserCollectionRestore).pipe(
|
||||
switchMap((enabled) => {
|
||||
if (enabled) {
|
||||
return this.organizationUserService.restoreUser(organization, userId);
|
||||
} else {
|
||||
return from(
|
||||
this.organizationUserApiService.restoreOrganizationUser(organization.id, userId),
|
||||
);
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
this.organizationMetadataService.refreshMetadataCache();
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user