mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00:00
[EC 784] Refactor organization user service (#4163)
* [EC-784] Introduce OrganizationUserService and abstraction * [EC-784] Move API response models into abstraction folder * [EC-784] Register OrganizationUserService in JsLib * [EC-784] Add OrganizationUserService to CLI Main * [EC-784] Move getOrganizationUser() - Move getOrganizationUser() implementation to OrganizationUserService - Update any references to the API service in the CLI and Web projects * [EC-784] Move getOrganizationUserGroups() * [EC-784] Move and rename getOrganizationUsers() * [EC-784] Move getOrganizationUserResetPasswordDetails() * [EC-784] Move OrganizationUser API request models into abstraction folder * [EC-784] Move postOrganizationUserInvite() * [EC-784] Move postOrganizationUserReinvite() * [EC-784] Move postManyOrganizationUserReinvite() Also tweak the signature to avoid exposing the API request model * [EC-784] Move postOrganizationUserAccept() * [EC-784] Move postOrganizationUserConfirm() * [EC-784] Move postOrganizationUsersPublicKey() Also modify signature to avoid exposing API request model * [EC-784] Move postOrganizationUserBulkConfirm() * [EC-784] Move putOrganizationUser() * [EC-784] Move putOrganizationUserGroups() * [EC-784] Update abstraction method definitions to use abstract keyword * [EC-784] Move putOrganizationUserResetPasswordEnrollment() * [EC-784] Move putOrganizationUserResetPassword() * [EC-784] Move deleteOrganizationUser() * [EC-784] Move deleteManyOrganizationUsers() * [EC-784] Move revokeOrganizationUser() * [EC-784] Move revokeManyOrganizationUsers() * [EC-784] Move restoreOrganizationUser() * [EC-784] Move restoreManyOrganizationUsers() * [EC-784] Move internal OrganizationUserBulkRequest model out of service abstraction * [EC-784] Rename organizationUser folder to organization-user
This commit is contained in:
@@ -42,15 +42,6 @@ import { KeyConnectorUserKeyRequest } from "../models/request/key-connector-user
|
||||
import { KeysRequest } from "../models/request/keys.request";
|
||||
import { OrganizationConnectionRequest } from "../models/request/organization-connection.request";
|
||||
import { OrganizationImportRequest } from "../models/request/organization-import.request";
|
||||
import { OrganizationUserAcceptRequest } from "../models/request/organization-user-accept.request";
|
||||
import { OrganizationUserBulkConfirmRequest } from "../models/request/organization-user-bulk-confirm.request";
|
||||
import { OrganizationUserBulkRequest } from "../models/request/organization-user-bulk.request";
|
||||
import { OrganizationUserConfirmRequest } from "../models/request/organization-user-confirm.request";
|
||||
import { OrganizationUserInviteRequest } from "../models/request/organization-user-invite.request";
|
||||
import { OrganizationUserResetPasswordEnrollmentRequest } from "../models/request/organization-user-reset-password-enrollment.request";
|
||||
import { OrganizationUserResetPasswordRequest } from "../models/request/organization-user-reset-password.request";
|
||||
import { OrganizationUserUpdateGroupsRequest } from "../models/request/organization-user-update-groups.request";
|
||||
import { OrganizationUserUpdateRequest } from "../models/request/organization-user-update.request";
|
||||
import { OrganizationSponsorshipCreateRequest } from "../models/request/organization/organization-sponsorship-create.request";
|
||||
import { OrganizationSponsorshipRedeemRequest } from "../models/request/organization/organization-sponsorship-redeem.request";
|
||||
import { PasswordHintRequest } from "../models/request/password-hint.request";
|
||||
@@ -126,13 +117,6 @@ import {
|
||||
} from "../models/response/organization-connection.response";
|
||||
import { OrganizationExportResponse } from "../models/response/organization-export.response";
|
||||
import { OrganizationSponsorshipSyncStatusResponse } from "../models/response/organization-sponsorship-sync-status.response";
|
||||
import { OrganizationUserBulkPublicKeyResponse } from "../models/response/organization-user-bulk-public-key.response";
|
||||
import { OrganizationUserBulkResponse } from "../models/response/organization-user-bulk.response";
|
||||
import {
|
||||
OrganizationUserDetailsResponse,
|
||||
OrganizationUserUserDetailsResponse,
|
||||
OrganizationUserResetPasswordDetailsReponse,
|
||||
} from "../models/response/organization-user.response";
|
||||
import { PaymentResponse } from "../models/response/payment.response";
|
||||
import { PlanResponse } from "../models/response/plan.response";
|
||||
import { PolicyResponse } from "../models/response/policy.response";
|
||||
@@ -165,8 +149,8 @@ import { TwoFactorEmailResponse } from "../models/response/two-factor-email.resp
|
||||
import { TwoFactorProviderResponse } from "../models/response/two-factor-provider.response";
|
||||
import { TwoFactorRecoverResponse } from "../models/response/two-factor-recover.response";
|
||||
import {
|
||||
TwoFactorWebAuthnResponse,
|
||||
ChallengeResponse,
|
||||
TwoFactorWebAuthnResponse,
|
||||
} from "../models/response/two-factor-web-authn.response";
|
||||
import { TwoFactorYubiKeyResponse } from "../models/response/two-factor-yubi-key.response";
|
||||
import { UserKeyResponse } from "../models/response/user-key.response";
|
||||
@@ -1016,281 +1000,6 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
);
|
||||
}
|
||||
|
||||
// Organization User APIs
|
||||
|
||||
async getOrganizationUser(
|
||||
organizationId: string,
|
||||
id: string
|
||||
): Promise<OrganizationUserDetailsResponse> {
|
||||
const r = await this.send(
|
||||
"GET",
|
||||
"/organizations/" + organizationId + "/users/" + id,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new OrganizationUserDetailsResponse(r);
|
||||
}
|
||||
|
||||
async getOrganizationUserGroups(organizationId: string, id: string): Promise<string[]> {
|
||||
const r = await this.send(
|
||||
"GET",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/groups",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return r;
|
||||
}
|
||||
|
||||
async getOrganizationUsers(
|
||||
organizationId: string
|
||||
): Promise<ListResponse<OrganizationUserUserDetailsResponse>> {
|
||||
const r = await this.send(
|
||||
"GET",
|
||||
"/organizations/" + organizationId + "/users",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserUserDetailsResponse);
|
||||
}
|
||||
|
||||
async getOrganizationUserResetPasswordDetails(
|
||||
organizationId: string,
|
||||
id: string
|
||||
): Promise<OrganizationUserResetPasswordDetailsReponse> {
|
||||
const r = await this.send(
|
||||
"GET",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/reset-password-details",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new OrganizationUserResetPasswordDetailsReponse(r);
|
||||
}
|
||||
|
||||
postOrganizationUserInvite(
|
||||
organizationId: string,
|
||||
request: OrganizationUserInviteRequest
|
||||
): Promise<any> {
|
||||
return this.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/invite",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
postOrganizationUserReinvite(organizationId: string, id: string): Promise<any> {
|
||||
return this.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/reinvite",
|
||||
null,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
async postManyOrganizationUserReinvite(
|
||||
organizationId: string,
|
||||
request: OrganizationUserBulkRequest
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/reinvite",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
|
||||
postOrganizationUserAccept(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserAcceptRequest
|
||||
): Promise<any> {
|
||||
return this.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/accept",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
postOrganizationUserConfirm(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserConfirmRequest
|
||||
): Promise<any> {
|
||||
return this.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/confirm",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
async postOrganizationUsersPublicKey(
|
||||
organizationId: string,
|
||||
request: OrganizationUserBulkRequest
|
||||
): Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>> {
|
||||
const r = await this.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/public-keys",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkPublicKeyResponse);
|
||||
}
|
||||
|
||||
async postOrganizationUserBulkConfirm(
|
||||
organizationId: string,
|
||||
request: OrganizationUserBulkConfirmRequest
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/confirm",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
|
||||
putOrganizationUser(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserUpdateRequest
|
||||
): Promise<any> {
|
||||
return this.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + id,
|
||||
request,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
putOrganizationUserGroups(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserUpdateGroupsRequest
|
||||
): Promise<any> {
|
||||
return this.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/groups",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
putOrganizationUserResetPasswordEnrollment(
|
||||
organizationId: string,
|
||||
userId: string,
|
||||
request: OrganizationUserResetPasswordEnrollmentRequest
|
||||
): Promise<void> {
|
||||
return this.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + userId + "/reset-password-enrollment",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
putOrganizationUserResetPassword(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserResetPasswordRequest
|
||||
): Promise<any> {
|
||||
return this.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/reset-password",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
deleteOrganizationUser(organizationId: string, id: string): Promise<any> {
|
||||
return this.send(
|
||||
"DELETE",
|
||||
"/organizations/" + organizationId + "/users/" + id,
|
||||
null,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
async deleteManyOrganizationUsers(
|
||||
organizationId: string,
|
||||
request: OrganizationUserBulkRequest
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.send(
|
||||
"DELETE",
|
||||
"/organizations/" + organizationId + "/users",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
|
||||
revokeOrganizationUser(organizationId: string, id: string): Promise<any> {
|
||||
return this.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/revoke",
|
||||
null,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
async revokeManyOrganizationUsers(
|
||||
organizationId: string,
|
||||
request: OrganizationUserBulkRequest
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/revoke",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
|
||||
restoreOrganizationUser(organizationId: string, id: string): Promise<any> {
|
||||
return this.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/restore",
|
||||
null,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
async restoreManyOrganizationUsers(
|
||||
organizationId: string,
|
||||
request: OrganizationUserBulkRequest
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/restore",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
|
||||
// Plan APIs
|
||||
|
||||
async getPlans(): Promise<ListResponse<PlanResponse>> {
|
||||
|
||||
Reference in New Issue
Block a user