mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +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,
|
OrganizationUserApiService,
|
||||||
OrganizationUserInviteRequest,
|
OrganizationUserInviteRequest,
|
||||||
OrganizationUserUpdateRequest,
|
OrganizationUserUpdateRequest,
|
||||||
OrganizationUserDetailsResponse,
|
|
||||||
} from "@bitwarden/admin-console/common";
|
} from "@bitwarden/admin-console/common";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
|
||||||
|
|
||||||
import { CoreOrganizationModule } from "../core-organization.module";
|
import { CoreOrganizationModule } from "../core-organization.module";
|
||||||
import { OrganizationUserAdminView } from "../views/organization-user-admin-view";
|
import { OrganizationUserAdminView } from "../views/organization-user-admin-view";
|
||||||
|
|
||||||
@Injectable({ providedIn: CoreOrganizationModule })
|
@Injectable({ providedIn: CoreOrganizationModule })
|
||||||
export class UserAdminService {
|
export class UserAdminService {
|
||||||
constructor(
|
constructor(private organizationUserApiService: OrganizationUserApiService) {}
|
||||||
private configService: ConfigService,
|
|
||||||
private organizationUserApiService: OrganizationUserApiService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async get(
|
async get(
|
||||||
organizationId: string,
|
organizationId: string,
|
||||||
@ -34,9 +29,7 @@ export class UserAdminService {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [view] = await this.decryptMany(organizationId, [userResponse]);
|
return OrganizationUserAdminView.fromResponse(organizationId, userResponse);
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async save(user: OrganizationUserAdminView): Promise<void> {
|
async save(user: OrganizationUserAdminView): Promise<void> {
|
||||||
@ -65,35 +58,4 @@ export class UserAdminService {
|
|||||||
|
|
||||||
await this.organizationUserApiService.postOrganizationUserInvite(user.organizationId, request);
|
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 {
|
import {
|
||||||
OrganizationUserStatusType,
|
OrganizationUserStatusType,
|
||||||
OrganizationUserType,
|
OrganizationUserType,
|
||||||
@ -15,9 +18,38 @@ export class OrganizationUserAdminView {
|
|||||||
permissions: PermissionsApi;
|
permissions: PermissionsApi;
|
||||||
resetPasswordEnrolled: boolean;
|
resetPasswordEnrolled: boolean;
|
||||||
hasMasterPassword: boolean;
|
hasMasterPassword: boolean;
|
||||||
|
managedByOrganization: boolean;
|
||||||
|
|
||||||
collections: CollectionAccessSelectionView[] = [];
|
collections: CollectionAccessSelectionView[] = [];
|
||||||
groups: string[] = [];
|
groups: string[] = [];
|
||||||
|
|
||||||
accessSecretsManager: boolean;
|
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.
|
* True if this organizaztion user has been granted access to Secrets Manager, false otherwise.
|
||||||
*/
|
*/
|
||||||
accessSecretsManager: boolean;
|
accessSecretsManager: boolean;
|
||||||
|
managedByOrganization: boolean;
|
||||||
|
|
||||||
collections: CollectionAccessSelectionView[] = [];
|
collections: CollectionAccessSelectionView[] = [];
|
||||||
groups: string[] = [];
|
groups: string[] = [];
|
||||||
|
@ -49,6 +49,7 @@ export class OrganizationUserUserDetailsResponse extends OrganizationUserRespons
|
|||||||
avatarColor: string;
|
avatarColor: string;
|
||||||
twoFactorEnabled: boolean;
|
twoFactorEnabled: boolean;
|
||||||
usesKeyConnector: boolean;
|
usesKeyConnector: boolean;
|
||||||
|
managedByOrganization: boolean;
|
||||||
|
|
||||||
constructor(response: any) {
|
constructor(response: any) {
|
||||||
super(response);
|
super(response);
|
||||||
@ -57,12 +58,16 @@ export class OrganizationUserUserDetailsResponse extends OrganizationUserRespons
|
|||||||
this.avatarColor = this.getResponseProperty("AvatarColor");
|
this.avatarColor = this.getResponseProperty("AvatarColor");
|
||||||
this.twoFactorEnabled = this.getResponseProperty("TwoFactorEnabled");
|
this.twoFactorEnabled = this.getResponseProperty("TwoFactorEnabled");
|
||||||
this.usesKeyConnector = this.getResponseProperty("UsesKeyConnector") ?? false;
|
this.usesKeyConnector = this.getResponseProperty("UsesKeyConnector") ?? false;
|
||||||
|
this.managedByOrganization = this.getResponseProperty("ManagedByOrganization") ?? false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class OrganizationUserDetailsResponse extends OrganizationUserResponse {
|
export class OrganizationUserDetailsResponse extends OrganizationUserResponse {
|
||||||
|
managedByOrganization: boolean;
|
||||||
|
|
||||||
constructor(response: any) {
|
constructor(response: any) {
|
||||||
super(response);
|
super(response);
|
||||||
|
this.managedByOrganization = this.getResponseProperty("ManagedByOrganization") ?? false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user