mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-21 16:18:28 +01:00
[PM-12758] Add managed status to OrganizationUserDetailsResponse, OrganizationUserUserDetailsResponse, OrganizationUserView and OrganizationUserAdminView (#11640)
* Add managedByOrganization property to OrganizationUserUserDetailsResponse and OrganizationUserView * Add managedByOrganization property to OrganizationUserDetailsResponse and OrganizationUserAdminView * Move response mapping from UserAdminService to method in OrganizationUserAdminView
This commit is contained in:
parent
15c301d39f
commit
548abfe906
@ -4,19 +4,14 @@ import {
|
||||
OrganizationUserApiService,
|
||||
OrganizationUserInviteRequest,
|
||||
OrganizationUserUpdateRequest,
|
||||
OrganizationUserDetailsResponse,
|
||||
} from "@bitwarden/admin-console/common";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
|
||||
import { CoreOrganizationModule } from "../core-organization.module";
|
||||
import { OrganizationUserAdminView } from "../views/organization-user-admin-view";
|
||||
|
||||
@Injectable({ providedIn: CoreOrganizationModule })
|
||||
export class UserAdminService {
|
||||
constructor(
|
||||
private configService: ConfigService,
|
||||
private organizationUserApiService: OrganizationUserApiService,
|
||||
) {}
|
||||
constructor(private organizationUserApiService: OrganizationUserApiService) {}
|
||||
|
||||
async get(
|
||||
organizationId: string,
|
||||
@ -34,9 +29,7 @@ export class UserAdminService {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const [view] = await this.decryptMany(organizationId, [userResponse]);
|
||||
|
||||
return view;
|
||||
return OrganizationUserAdminView.fromResponse(organizationId, userResponse);
|
||||
}
|
||||
|
||||
async save(user: OrganizationUserAdminView): Promise<void> {
|
||||
@ -65,35 +58,4 @@ export class UserAdminService {
|
||||
|
||||
await this.organizationUserApiService.postOrganizationUserInvite(user.organizationId, request);
|
||||
}
|
||||
|
||||
private async decryptMany(
|
||||
organizationId: string,
|
||||
users: OrganizationUserDetailsResponse[],
|
||||
): Promise<OrganizationUserAdminView[]> {
|
||||
const promises = users.map(async (u) => {
|
||||
const view = new OrganizationUserAdminView();
|
||||
|
||||
view.id = u.id;
|
||||
view.organizationId = organizationId;
|
||||
view.userId = u.userId;
|
||||
view.type = u.type;
|
||||
view.status = u.status;
|
||||
view.externalId = u.externalId;
|
||||
view.permissions = u.permissions;
|
||||
view.resetPasswordEnrolled = u.resetPasswordEnrolled;
|
||||
view.collections = u.collections.map((c) => ({
|
||||
id: c.id,
|
||||
hidePasswords: c.hidePasswords,
|
||||
readOnly: c.readOnly,
|
||||
manage: c.manage,
|
||||
}));
|
||||
view.groups = u.groups;
|
||||
view.accessSecretsManager = u.accessSecretsManager;
|
||||
view.hasMasterPassword = u.hasMasterPassword;
|
||||
|
||||
return view;
|
||||
});
|
||||
|
||||
return await Promise.all(promises);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
import { CollectionAccessSelectionView } from "@bitwarden/admin-console/common";
|
||||
import {
|
||||
CollectionAccessSelectionView,
|
||||
OrganizationUserDetailsResponse,
|
||||
} from "@bitwarden/admin-console/common";
|
||||
import {
|
||||
OrganizationUserStatusType,
|
||||
OrganizationUserType,
|
||||
@ -15,9 +18,38 @@ export class OrganizationUserAdminView {
|
||||
permissions: PermissionsApi;
|
||||
resetPasswordEnrolled: boolean;
|
||||
hasMasterPassword: boolean;
|
||||
managedByOrganization: boolean;
|
||||
|
||||
collections: CollectionAccessSelectionView[] = [];
|
||||
groups: string[] = [];
|
||||
|
||||
accessSecretsManager: boolean;
|
||||
|
||||
static fromResponse(
|
||||
organizationId: string,
|
||||
response: OrganizationUserDetailsResponse,
|
||||
): OrganizationUserAdminView {
|
||||
const view = new OrganizationUserAdminView();
|
||||
|
||||
view.id = response.id;
|
||||
view.organizationId = organizationId;
|
||||
view.userId = response.userId;
|
||||
view.type = response.type;
|
||||
view.status = response.status;
|
||||
view.externalId = response.externalId;
|
||||
view.permissions = response.permissions;
|
||||
view.resetPasswordEnrolled = response.resetPasswordEnrolled;
|
||||
view.collections = response.collections.map((c) => ({
|
||||
id: c.id,
|
||||
hidePasswords: c.hidePasswords,
|
||||
readOnly: c.readOnly,
|
||||
manage: c.manage,
|
||||
}));
|
||||
view.groups = response.groups;
|
||||
view.accessSecretsManager = response.accessSecretsManager;
|
||||
view.hasMasterPassword = response.hasMasterPassword;
|
||||
view.managedByOrganization = response.managedByOrganization;
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ export class OrganizationUserView {
|
||||
* True if this organizaztion user has been granted access to Secrets Manager, false otherwise.
|
||||
*/
|
||||
accessSecretsManager: boolean;
|
||||
managedByOrganization: boolean;
|
||||
|
||||
collections: CollectionAccessSelectionView[] = [];
|
||||
groups: string[] = [];
|
||||
|
@ -49,6 +49,7 @@ export class OrganizationUserUserDetailsResponse extends OrganizationUserRespons
|
||||
avatarColor: string;
|
||||
twoFactorEnabled: boolean;
|
||||
usesKeyConnector: boolean;
|
||||
managedByOrganization: boolean;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
@ -57,12 +58,16 @@ export class OrganizationUserUserDetailsResponse extends OrganizationUserRespons
|
||||
this.avatarColor = this.getResponseProperty("AvatarColor");
|
||||
this.twoFactorEnabled = this.getResponseProperty("TwoFactorEnabled");
|
||||
this.usesKeyConnector = this.getResponseProperty("UsesKeyConnector") ?? false;
|
||||
this.managedByOrganization = this.getResponseProperty("ManagedByOrganization") ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
export class OrganizationUserDetailsResponse extends OrganizationUserResponse {
|
||||
managedByOrganization: boolean;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
this.managedByOrganization = this.getResponseProperty("ManagedByOrganization") ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user