1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-25 12:15:18 +01: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:
Shane Melton 2022-12-19 10:56:16 -08:00 committed by GitHub
parent d18c32ab32
commit f67fffcc08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 764 additions and 511 deletions

View File

@ -6,6 +6,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
@ -32,7 +33,8 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
router: Router,
syncService: SyncService,
route: ActivatedRoute,
organizationApiService: OrganizationApiServiceAbstraction
organizationApiService: OrganizationApiServiceAbstraction,
organizationUserService: OrganizationUserService
) {
super(
i18nService,
@ -47,7 +49,8 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
syncService,
route,
stateService,
organizationApiService
organizationApiService,
organizationUserService
);
}
}

View File

@ -5,6 +5,7 @@ import * as program from "commander";
import * as jsdom from "jsdom";
import { InternalFolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { ClientType } from "@bitwarden/common/enums/clientType";
import { KeySuffixOptions } from "@bitwarden/common/enums/keySuffixOptions";
@ -30,6 +31,7 @@ import { ImportService } from "@bitwarden/common/services/import.service";
import { KeyConnectorService } from "@bitwarden/common/services/keyConnector.service";
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
import { NoopMessagingService } from "@bitwarden/common/services/noopMessaging.service";
import { OrganizationUserServiceImplementation } from "@bitwarden/common/services/organization-user/organization-user.service.implementation";
import { OrganizationApiService } from "@bitwarden/common/services/organization/organization-api.service";
import { OrganizationService } from "@bitwarden/common/services/organization/organization.service";
import { PasswordGenerationService } from "@bitwarden/common/services/passwordGeneration.service";
@ -82,6 +84,7 @@ export class Main {
settingsService: SettingsService;
cipherService: CipherService;
folderService: InternalFolderService;
organizationUserService: OrganizationUserService;
collectionService: CollectionService;
vaultTimeoutService: VaultTimeoutService;
vaultTimeoutSettingsService: VaultTimeoutSettingsService;
@ -242,6 +245,8 @@ export class Main {
this.organizationService = new OrganizationService(this.stateService);
this.organizationUserService = new OrganizationUserServiceImplementation(this.apiService);
this.policyService = new PolicyService(this.stateService, this.organizationService);
this.sendService = new SendService(

View File

@ -1,12 +1,17 @@
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserConfirmRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { Utils } from "@bitwarden/common/misc/utils";
import { OrganizationUserConfirmRequest } from "@bitwarden/common/models/request/organization-user-confirm.request";
import { Response } from "../models/response";
export class ConfirmCommand {
constructor(private apiService: ApiService, private cryptoService: CryptoService) {}
constructor(
private apiService: ApiService,
private cryptoService: CryptoService,
private organizationUserService: OrganizationUserService
) {}
async run(object: string, id: string, cmdOptions: Record<string, any>): Promise<Response> {
if (id != null) {
@ -37,7 +42,10 @@ export class ConfirmCommand {
if (orgKey == null) {
throw new Error("No encryption key for this organization.");
}
const orgUser = await this.apiService.getOrganizationUser(options.organizationId, id);
const orgUser = await this.organizationUserService.getOrganizationUser(
options.organizationId,
id
);
if (orgUser == null) {
throw new Error("Member id does not exist for this organization.");
}
@ -46,7 +54,11 @@ export class ConfirmCommand {
const key = await this.cryptoService.rsaEncrypt(orgKey.key, publicKey.buffer);
const req = new OrganizationUserConfirmRequest();
req.key = key.encryptedString;
await this.apiService.postOrganizationUserConfirm(options.organizationId, id, req);
await this.organizationUserService.postOrganizationUserConfirm(
options.organizationId,
id,
req
);
return Response.success();
} catch (e) {
return Response.error(e);

View File

@ -2,6 +2,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CipherService } from "@bitwarden/common/abstractions/cipher.service";
import { CollectionService } from "@bitwarden/common/abstractions/collection.service";
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { Utils } from "@bitwarden/common/misc/utils";
@ -30,6 +31,7 @@ export class ListCommand {
private collectionService: CollectionService,
private organizationService: OrganizationService,
private searchService: SearchService,
private organizationUserService: OrganizationUserService,
private apiService: ApiService
) {}
@ -202,7 +204,7 @@ export class ListCommand {
}
try {
const response = await this.apiService.getOrganizationUsers(options.organizationId);
const response = await this.organizationUserService.getAllUsers(options.organizationId);
const res = new ListResponse(
response.data.map((r) => {
const u = new OrganizationUserResponse();

View File

@ -73,6 +73,7 @@ export class ServeCommand {
this.main.collectionService,
this.main.organizationService,
this.main.searchService,
this.main.organizationUserService,
this.main.apiService
);
this.createCommand = new CreateCommand(
@ -108,7 +109,11 @@ export class ServeCommand {
this.main.apiService,
this.main.folderApiService
);
this.confirmCommand = new ConfirmCommand(this.main.apiService, this.main.cryptoService);
this.confirmCommand = new ConfirmCommand(
this.main.apiService,
this.main.cryptoService,
this.main.organizationUserService
);
this.restoreCommand = new RestoreCommand(this.main.cipherService);
this.shareCommand = new ShareCommand(this.main.cipherService);
this.lockCommand = new LockCommand(this.main.vaultTimeoutService);

View File

@ -115,6 +115,7 @@ export class VaultProgram extends Program {
this.main.collectionService,
this.main.organizationService,
this.main.searchService,
this.main.organizationUserService,
this.main.apiService
);
const response = await command.run(object, cmd);
@ -410,7 +411,11 @@ export class VaultProgram extends Program {
}
await this.exitIfLocked();
const command = new ConfirmCommand(this.main.apiService, this.main.cryptoService);
const command = new ConfirmCommand(
this.main.apiService,
this.main.cryptoService,
this.main.organizationUserService
);
const response = await command.run(object, id, cmd);
this.processResponse(response);
});

View File

@ -7,6 +7,7 @@ import { BroadcasterService } from "@bitwarden/common/abstractions/broadcaster.s
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
@ -37,7 +38,8 @@ export class SetPasswordComponent extends BaseSetPasswordComponent implements On
private broadcasterService: BroadcasterService,
private ngZone: NgZone,
stateService: StateService,
organizationApiService: OrganizationApiServiceAbstraction
organizationApiService: OrganizationApiServiceAbstraction,
organizationUserService: OrganizationUserService
) {
super(
i18nService,
@ -52,7 +54,8 @@ export class SetPasswordComponent extends BaseSetPasswordComponent implements On
syncService,
route,
stateService,
organizationApiService
organizationApiService,
organizationUserService
);
}

View File

@ -5,6 +5,8 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserAcceptRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { PolicyApiServiceAbstraction } from "@bitwarden/common/abstractions/policy/policy-api.service.abstraction";
@ -12,7 +14,6 @@ import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.serv
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { Utils } from "@bitwarden/common/misc/utils";
import { Policy } from "@bitwarden/common/models/domain/policy";
import { OrganizationUserAcceptRequest } from "@bitwarden/common/models/request/organization-user-accept.request";
import { BaseAcceptComponent } from "../common/base.accept.component";
@ -36,14 +37,15 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
private policyApiService: PolicyApiServiceAbstraction,
private policyService: PolicyService,
private logService: LogService,
private organizationApiService: OrganizationApiServiceAbstraction
private organizationApiService: OrganizationApiServiceAbstraction,
private organizationUserService: OrganizationUserService
) {
super(router, platformUtilsService, i18nService, route, stateService);
}
async authedHandler(qParams: Params): Promise<void> {
this.actionPromise = this.prepareAcceptRequest(qParams).then(async (request) => {
await this.apiService.postOrganizationUserAccept(
await this.organizationUserService.postOrganizationUserAccept(
qParams.organizationId,
qParams.organizationUserId,
request

View File

@ -6,6 +6,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
@ -32,7 +33,8 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
syncService: SyncService,
route: ActivatedRoute,
stateService: StateService,
organizationApiService: OrganizationApiServiceAbstraction
organizationApiService: OrganizationApiServiceAbstraction,
organizationUserService: OrganizationUserService
) {
super(
i18nService,
@ -47,7 +49,8 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
syncService,
route,
stateService,
organizationApiService
organizationApiService,
organizationUserService
);
}
}

View File

@ -7,6 +7,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserUserDetailsResponse } from "@bitwarden/common/abstractions/organization-user/responses";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { StateService } from "@bitwarden/common/abstractions/state.service";
@ -17,7 +18,6 @@ import { ProviderUserStatusType } from "@bitwarden/common/enums/providerUserStat
import { ProviderUserType } from "@bitwarden/common/enums/providerUserType";
import { Utils } from "@bitwarden/common/misc/utils";
import { ListResponse } from "@bitwarden/common/models/response/list.response";
import { OrganizationUserUserDetailsResponse } from "@bitwarden/common/models/response/organization-user.response";
import { ProviderUserUserDetailsResponse } from "@bitwarden/common/models/response/provider/provider-user.response";
import { UserConfirmComponent } from "../organizations/manage/user-confirm.component";

View File

@ -3,10 +3,10 @@ import { Component, Input, OnInit } from "@angular/core";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserBulkConfirmRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { OrganizationUserStatusType } from "@bitwarden/common/enums/organizationUserStatusType";
import { Utils } from "@bitwarden/common/misc/utils";
import { OrganizationUserBulkConfirmRequest } from "@bitwarden/common/models/request/organization-user-bulk-confirm.request";
import { OrganizationUserBulkRequest } from "@bitwarden/common/models/request/organization-user-bulk.request";
import { BulkUserDetails } from "./bulk-status.component";
@ -31,6 +31,7 @@ export class BulkConfirmComponent implements OnInit {
constructor(
protected cryptoService: CryptoService,
protected apiService: ApiService,
private organizationUserService: OrganizationUserService,
private i18nService: I18nService
) {}
@ -91,8 +92,10 @@ export class BulkConfirmComponent implements OnInit {
}
protected async getPublicKeys() {
const request = new OrganizationUserBulkRequest(this.filteredUsers.map((user) => user.id));
return await this.apiService.postOrganizationUsersPublicKey(this.organizationId, request);
return await this.organizationUserService.postOrganizationUsersPublicKey(
this.organizationId,
this.filteredUsers.map((user) => user.id)
);
}
protected getCryptoKey() {
@ -101,6 +104,9 @@ export class BulkConfirmComponent implements OnInit {
protected async postConfirmRequest(userIdsWithKeys: any[]) {
const request = new OrganizationUserBulkConfirmRequest(userIdsWithKeys);
return await this.apiService.postOrganizationUserBulkConfirm(this.organizationId, request);
return await this.organizationUserService.postOrganizationUserBulkConfirm(
this.organizationId,
request
);
}
}

View File

@ -2,7 +2,7 @@ import { Component, Input } from "@angular/core";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { OrganizationUserBulkRequest } from "@bitwarden/common/models/request/organization-user-bulk.request";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { BulkUserDetails } from "./bulk-status.component";
@ -20,7 +20,11 @@ export class BulkRemoveComponent {
done = false;
error: string;
constructor(protected apiService: ApiService, protected i18nService: I18nService) {}
constructor(
protected apiService: ApiService,
protected i18nService: I18nService,
private organizationUserService: OrganizationUserService
) {}
async submit() {
this.loading = true;
@ -40,8 +44,10 @@ export class BulkRemoveComponent {
}
protected async deleteUsers() {
const request = new OrganizationUserBulkRequest(this.users.map((user) => user.id));
return await this.apiService.deleteManyOrganizationUsers(this.organizationId, request);
return await this.organizationUserService.deleteManyOrganizationUsers(
this.organizationId,
this.users.map((user) => user.id)
);
}
protected get removeUsersWarning() {

View File

@ -1,9 +1,8 @@
import { Component } from "@angular/core";
import { ModalConfig } from "@bitwarden/angular/services/modal.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { OrganizationUserBulkRequest } from "@bitwarden/common/models/request/organization-user-bulk.request";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { BulkUserDetails } from "./bulk-status.component";
@ -23,8 +22,8 @@ export class BulkRestoreRevokeComponent {
error: string;
constructor(
protected apiService: ApiService,
protected i18nService: I18nService,
private organizationUserService: OrganizationUserService,
config: ModalConfig
) {
this.isRevoking = config.data.isRevoking;
@ -56,11 +55,17 @@ export class BulkRestoreRevokeComponent {
}
protected async performBulkUserAction() {
const request = new OrganizationUserBulkRequest(this.users.map((user) => user.id));
const userIds = this.users.map((user) => user.id);
if (this.isRevoking) {
return await this.apiService.revokeManyOrganizationUsers(this.organizationId, request);
return await this.organizationUserService.revokeManyOrganizationUsers(
this.organizationId,
userIds
);
} else {
return await this.apiService.restoreManyOrganizationUsers(this.organizationId, request);
return await this.organizationUserService.restoreManyOrganizationUsers(
this.organizationId,
userIds
);
}
}
}

View File

@ -4,6 +4,7 @@ import { UserNamePipe } from "@bitwarden/angular/pipes/user-name.pipe";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { EventResponse } from "@bitwarden/common/models/response/event.response";
import { ListResponse } from "@bitwarden/common/models/response/list.response";
@ -40,7 +41,8 @@ export class EntityEventsComponent implements OnInit {
private eventService: EventService,
private platformUtilsService: PlatformUtilsService,
private userNamePipe: UserNamePipe,
private logService: LogService
private logService: LogService,
private organizationUserService: OrganizationUserService
) {}
async ngOnInit() {
@ -52,7 +54,7 @@ export class EntityEventsComponent implements OnInit {
async load() {
if (this.showUser) {
const response = await this.apiService.getOrganizationUsers(this.organizationId);
const response = await this.organizationUserService.getAllUsers(this.organizationId);
response.data.forEach((u) => {
const name = this.userNamePipe.transform(u);
this.orgUsersIdMap.set(u.id, { name: name, email: u.email });

View File

@ -4,12 +4,13 @@ import { SearchPipe } from "@bitwarden/angular/pipes/search.pipe";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserUserDetailsResponse } from "@bitwarden/common/abstractions/organization-user/responses";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { OrganizationUserStatusType } from "@bitwarden/common/enums/organizationUserStatusType";
import { OrganizationUserType } from "@bitwarden/common/enums/organizationUserType";
import { Utils } from "@bitwarden/common/misc/utils";
import { SelectionReadOnlyRequest } from "@bitwarden/common/models/request/selection-read-only.request";
import { OrganizationUserUserDetailsResponse } from "@bitwarden/common/models/response/organization-user.response";
@Component({
selector: "app-entity-users",
@ -39,6 +40,7 @@ export class EntityUsersComponent implements OnInit {
private apiService: ApiService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private organizationUserService: OrganizationUserService,
private logService: LogService
) {}
@ -64,7 +66,7 @@ export class EntityUsersComponent implements OnInit {
}
async loadUsers() {
const users = await this.apiService.getOrganizationUsers(this.organizationId);
const users = await this.organizationUserService.getAllUsers(this.organizationId);
this.allUsers = users.data.map((r) => r).sort(Utils.getSortFunction(this.i18nService, "email"));
if (this.entity === "group") {
const response = await this.apiService.getGroupUsers(this.organizationId, this.entityId);

View File

@ -8,6 +8,7 @@ import { ExportService } from "@bitwarden/common/abstractions/export.service";
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { ProviderService } from "@bitwarden/common/abstractions/provider.service";
@ -41,6 +42,7 @@ export class EventsComponent extends BaseEventsComponent implements OnInit, OnDe
logService: LogService,
private userNamePipe: UserNamePipe,
private organizationService: OrganizationService,
private organizationUserService: OrganizationUserService,
private providerService: ProviderService,
fileDownloadService: FileDownloadService
) {
@ -72,7 +74,7 @@ export class EventsComponent extends BaseEventsComponent implements OnInit, OnDe
}
async load() {
const response = await this.apiService.getOrganizationUsers(this.organizationId);
const response = await this.organizationUserService.getAllUsers(this.organizationId);
response.data.forEach((u) => {
const name = this.userNamePipe.transform(u);
this.orgUsersUserIdMap.set(u.userId, { name: name, email: u.email });

View File

@ -9,6 +9,12 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserConfirmRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import {
OrganizationUserBulkResponse,
OrganizationUserUserDetailsResponse,
} from "@bitwarden/common/abstractions/organization-user/responses";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
@ -23,11 +29,7 @@ import { PolicyType } from "@bitwarden/common/enums/policyType";
import { ProductType } from "@bitwarden/common/enums/productType";
import { Organization } from "@bitwarden/common/models/domain/organization";
import { OrganizationKeysRequest } from "@bitwarden/common/models/request/organization-keys.request";
import { OrganizationUserBulkRequest } from "@bitwarden/common/models/request/organization-user-bulk.request";
import { OrganizationUserConfirmRequest } from "@bitwarden/common/models/request/organization-user-confirm.request";
import { ListResponse } from "@bitwarden/common/models/response/list.response";
import { OrganizationUserBulkResponse } from "@bitwarden/common/models/response/organization-user-bulk.response";
import { OrganizationUserUserDetailsResponse } from "@bitwarden/common/models/response/organization-user.response";
import { DialogService } from "@bitwarden/components";
import { BasePeopleComponent } from "../../common/base.people.component";
@ -92,6 +94,7 @@ export class PeopleComponent
stateService: StateService,
private organizationService: OrganizationService,
private organizationApiService: OrganizationApiServiceAbstraction,
private organizationUserService: OrganizationUserService,
private dialogService: DialogService
) {
super(
@ -167,23 +170,23 @@ export class PeopleComponent
}
getUsers(): Promise<ListResponse<OrganizationUserUserDetailsResponse>> {
return this.apiService.getOrganizationUsers(this.organization.id);
return this.organizationUserService.getAllUsers(this.organization.id);
}
deleteUser(id: string): Promise<void> {
return this.apiService.deleteOrganizationUser(this.organization.id, id);
return this.organizationUserService.deleteOrganizationUser(this.organization.id, id);
}
revokeUser(id: string): Promise<void> {
return this.apiService.revokeOrganizationUser(this.organization.id, id);
return this.organizationUserService.revokeOrganizationUser(this.organization.id, id);
}
restoreUser(id: string): Promise<void> {
return this.apiService.restoreOrganizationUser(this.organization.id, id);
return this.organizationUserService.restoreOrganizationUser(this.organization.id, id);
}
reinviteUser(id: string): Promise<void> {
return this.apiService.postOrganizationUserReinvite(this.organization.id, id);
return this.organizationUserService.postOrganizationUserReinvite(this.organization.id, id);
}
async confirmUser(
@ -194,7 +197,11 @@ export class PeopleComponent
const key = await this.cryptoService.rsaEncrypt(orgKey.key, publicKey.buffer);
const request = new OrganizationUserConfirmRequest();
request.key = key.encryptedString;
await this.apiService.postOrganizationUserConfirm(this.organization.id, user.id, request);
await this.organizationUserService.postOrganizationUserConfirm(
this.organization.id,
user.id,
request
);
}
allowResetPassword(orgUser: OrganizationUserUserDetailsResponse): boolean {
@ -377,10 +384,9 @@ export class PeopleComponent
}
try {
const request = new OrganizationUserBulkRequest(filteredUsers.map((user) => user.id));
const response = this.apiService.postManyOrganizationUserReinvite(
const response = this.organizationUserService.postManyOrganizationUserReinvite(
this.organization.id,
request
filteredUsers.map((user) => user.id)
);
this.showBulkStatus(
users,

View File

@ -11,17 +11,17 @@ import { Subject, takeUntil } from "rxjs";
import zxcvbn from "zxcvbn";
import { PasswordStrengthComponent } from "@bitwarden/angular/shared/components/password-strength/password-strength.component";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserResetPasswordRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
import { EncString } from "@bitwarden/common/models/domain/enc-string";
import { MasterPasswordPolicyOptions } from "@bitwarden/common/models/domain/master-password-policy-options";
import { SymmetricCryptoKey } from "@bitwarden/common/models/domain/symmetric-crypto-key";
import { OrganizationUserResetPasswordRequest } from "@bitwarden/common/models/request/organization-user-reset-password.request";
@Component({
selector: "app-reset-password",
@ -44,13 +44,13 @@ export class ResetPasswordComponent implements OnInit, OnDestroy {
private destroy$ = new Subject<void>();
constructor(
private apiService: ApiService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private passwordGenerationService: PasswordGenerationService,
private policyService: PolicyService,
private cryptoService: CryptoService,
private logService: LogService
private logService: LogService,
private organizationUserService: OrganizationUserService
) {}
async ngOnInit() {
@ -147,7 +147,7 @@ export class ResetPasswordComponent implements OnInit, OnDestroy {
// Get user Information (kdf type, kdf iterations, resetPasswordKey, private key) and change password
try {
this.formPromise = this.apiService
this.formPromise = this.organizationUserService
.getOrganizationUserResetPasswordDetails(this.organizationId, this.id)
.then(async (response) => {
if (response == null) {
@ -188,7 +188,7 @@ export class ResetPasswordComponent implements OnInit, OnDestroy {
request.newMasterPasswordHash = newPasswordHash;
// Change user's password
return this.apiService.putOrganizationUserResetPassword(
return this.organizationUserService.putOrganizationUserResetPassword(
this.organizationId,
this.id,
request

View File

@ -4,6 +4,11 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CollectionService } from "@bitwarden/common/abstractions/collection.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import {
OrganizationUserInviteRequest,
OrganizationUserUpdateRequest,
} from "@bitwarden/common/abstractions/organization-user/requests";
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { OrganizationUserStatusType } from "@bitwarden/common/enums/organizationUserStatusType";
@ -11,8 +16,6 @@ import { OrganizationUserType } from "@bitwarden/common/enums/organizationUserTy
import { PermissionsApi } from "@bitwarden/common/models/api/permissions.api";
import { CollectionData } from "@bitwarden/common/models/data/collection.data";
import { Collection } from "@bitwarden/common/models/domain/collection";
import { OrganizationUserInviteRequest } from "@bitwarden/common/models/request/organization-user-invite.request";
import { OrganizationUserUpdateRequest } from "@bitwarden/common/models/request/organization-user-update.request";
import { SelectionReadOnlyRequest } from "@bitwarden/common/models/request/selection-read-only.request";
import { CollectionDetailsResponse } from "@bitwarden/common/models/response/collection.response";
import { CollectionView } from "@bitwarden/common/models/view/collection.view";
@ -87,7 +90,8 @@ export class UserAddEditComponent implements OnInit {
private collectionService: CollectionService,
private platformUtilsService: PlatformUtilsService,
private organizationService: OrganizationService,
private logService: LogService
private logService: LogService,
private organizationUserService: OrganizationUserService
) {}
async ngOnInit() {
@ -100,7 +104,7 @@ export class UserAddEditComponent implements OnInit {
this.editMode = true;
this.title = this.i18nService.t("editUser");
try {
const user = await this.apiService.getOrganizationUser(
const user = await this.organizationUserService.getOrganizationUser(
this.organizationId,
this.organizationUserId
);
@ -224,7 +228,7 @@ export class UserAddEditComponent implements OnInit {
}
try {
this.deletePromise = this.apiService.deleteOrganizationUser(
this.deletePromise = this.organizationUserService.deleteOrganizationUser(
this.organizationId,
this.organizationUserId
);
@ -259,7 +263,7 @@ export class UserAddEditComponent implements OnInit {
}
try {
this.formPromise = this.apiService.revokeOrganizationUser(
this.formPromise = this.organizationUserService.revokeOrganizationUser(
this.organizationId,
this.organizationUserId
);
@ -282,7 +286,7 @@ export class UserAddEditComponent implements OnInit {
}
try {
this.formPromise = this.apiService.restoreOrganizationUser(
this.formPromise = this.organizationUserService.restoreOrganizationUser(
this.organizationId,
this.organizationUserId
);
@ -308,7 +312,7 @@ export class UserAddEditComponent implements OnInit {
request.permissions ?? new PermissionsApi(),
request.type !== OrganizationUserType.Custom
);
this.formPromise = this.apiService.putOrganizationUser(
this.formPromise = this.organizationUserService.putOrganizationUser(
this.organizationId,
this.organizationUserId,
request
@ -325,6 +329,9 @@ export class UserAddEditComponent implements OnInit {
request.type !== OrganizationUserType.Custom
);
request.collections = collections;
this.formPromise = this.apiService.postOrganizationUserInvite(this.organizationId, request);
this.formPromise = this.organizationUserService.postOrganizationUserInvite(
this.organizationId,
request
);
}
}

View File

@ -3,9 +3,10 @@ import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserUpdateGroupsRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { Utils } from "@bitwarden/common/misc/utils";
import { OrganizationUserUpdateGroupsRequest } from "@bitwarden/common/models/request/organization-user-update-groups.request";
import { GroupResponse } from "@bitwarden/common/models/response/group.response";
@Component({
@ -26,7 +27,8 @@ export class UserGroupsComponent implements OnInit {
private apiService: ApiService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private logService: LogService
private logService: LogService,
private organizationUserService: OrganizationUserService
) {}
async ngOnInit() {
@ -36,7 +38,7 @@ export class UserGroupsComponent implements OnInit {
this.groups = groups;
try {
const userGroups = await this.apiService.getOrganizationUserGroups(
const userGroups = await this.organizationUserService.getOrganizationUserGroups(
this.organizationId,
this.organizationUserId
);
@ -71,7 +73,7 @@ export class UserGroupsComponent implements OnInit {
request.groupIds = this.groups.filter((g) => (g as any).checked).map((g) => g.id);
try {
this.formPromise = this.apiService.putOrganizationUserGroups(
this.formPromise = this.organizationUserService.putOrganizationUserGroups(
this.organizationId,
this.organizationUserId,
request

View File

@ -2,17 +2,17 @@ import { Component } from "@angular/core";
import { ModalRef } from "@bitwarden/angular/components/modal/modal.ref";
import { ModalConfig } from "@bitwarden/angular/services/modal.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { SyncService } from "@bitwarden/common/abstractions/sync/sync.service.abstraction";
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
import { Utils } from "@bitwarden/common/misc/utils";
import { Organization } from "@bitwarden/common/models/domain/organization";
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/models/request/organization-user-reset-password-enrollment.request";
import { Verification } from "@bitwarden/common/types/verification";
@Component({
@ -27,7 +27,6 @@ export class EnrollMasterPasswordReset {
constructor(
private userVerificationService: UserVerificationService,
private apiService: ApiService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private cryptoService: CryptoService,
@ -35,7 +34,8 @@ export class EnrollMasterPasswordReset {
private logService: LogService,
private modalRef: ModalRef,
config: ModalConfig,
private organizationApiService: OrganizationApiServiceAbstraction
private organizationApiService: OrganizationApiServiceAbstraction,
private organizationUserService: OrganizationUserService
) {
this.organization = config.data.organization;
}
@ -65,7 +65,7 @@ export class EnrollMasterPasswordReset {
// Create request and execute enrollment
request.resetPasswordKey = keyString;
await this.apiService.putOrganizationUserResetPasswordEnrollment(
await this.organizationUserService.putOrganizationUserResetPasswordEnrollment(
this.organization.id,
this.organization.userId,
request

View File

@ -10,6 +10,8 @@ import { FolderService } from "@bitwarden/common/abstractions/folder/folder.serv
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { KeyConnectorService } from "@bitwarden/common/abstractions/keyConnector.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
@ -25,7 +27,6 @@ import { SymmetricCryptoKey } from "@bitwarden/common/models/domain/symmetric-cr
import { CipherWithIdRequest } from "@bitwarden/common/models/request/cipher-with-id.request";
import { EmergencyAccessUpdateRequest } from "@bitwarden/common/models/request/emergency-access-update.request";
import { FolderWithIdRequest } from "@bitwarden/common/models/request/folder-with-id.request";
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/models/request/organization-user-reset-password-enrollment.request";
import { PasswordRequest } from "@bitwarden/common/models/request/password.request";
import { SendWithIdRequest } from "@bitwarden/common/models/request/send-with-id.request";
import { UpdateKeyRequest } from "@bitwarden/common/models/request/update-key.request";
@ -55,7 +56,8 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
private organizationService: OrganizationService,
private keyConnectorService: KeyConnectorService,
private router: Router,
private organizationApiService: OrganizationApiServiceAbstraction
private organizationApiService: OrganizationApiServiceAbstraction,
private organizationUserService: OrganizationUserService
) {
super(
i18nService,
@ -280,7 +282,11 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
request.masterPasswordHash = masterPasswordHash;
request.resetPasswordKey = encryptedKey.encryptedString;
await this.apiService.putOrganizationUserResetPasswordEnrollment(org.id, org.userId, request);
await this.organizationUserService.putOrganizationUserResetPasswordEnrollment(
org.id,
org.userId,
request
);
}
}
}

View File

@ -5,6 +5,8 @@ import { ModalService } from "@bitwarden/angular/services/modal.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
@ -12,7 +14,6 @@ import { SyncService } from "@bitwarden/common/abstractions/sync/sync.service.ab
import { PolicyType } from "@bitwarden/common/enums/policyType";
import { Organization } from "@bitwarden/common/models/domain/organization";
import { Policy } from "@bitwarden/common/models/domain/policy";
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/models/request/organization-user-reset-password-enrollment.request";
import { EnrollMasterPasswordReset } from "../../../organizations/users/enroll-master-password-reset.component";
@ -37,7 +38,8 @@ export class OrganizationOptionsComponent implements OnInit, OnDestroy {
private policyService: PolicyService,
private modalService: ModalService,
private logService: LogService,
private organizationApiService: OrganizationApiServiceAbstraction
private organizationApiService: OrganizationApiServiceAbstraction,
private organizationUserService: OrganizationUserService
) {}
async ngOnInit() {
@ -133,7 +135,7 @@ export class OrganizationOptionsComponent implements OnInit, OnDestroy {
const request = new OrganizationUserResetPasswordEnrollmentRequest();
request.masterPasswordHash = "ignored";
request.resetPasswordKey = null;
this.actionPromise = this.apiService.putOrganizationUserResetPasswordEnrollment(
this.actionPromise = this.organizationUserService.putOrganizationUserResetPasswordEnrollment(
this.organization.id,
this.organization.userId,
request

View File

@ -6,6 +6,8 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/abstractions/organization-user/requests";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
@ -19,7 +21,6 @@ import { Utils } from "@bitwarden/common/misc/utils";
import { EncString } from "@bitwarden/common/models/domain/enc-string";
import { SymmetricCryptoKey } from "@bitwarden/common/models/domain/symmetric-crypto-key";
import { KeysRequest } from "@bitwarden/common/models/request/keys.request";
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/models/request/organization-user-reset-password-enrollment.request";
import { SetPasswordRequest } from "@bitwarden/common/models/request/set-password.request";
import { ChangePasswordComponent as BaseChangePasswordComponent } from "./change-password.component";
@ -49,7 +50,8 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
private syncService: SyncService,
private route: ActivatedRoute,
stateService: StateService,
private organizationApiService: OrganizationApiServiceAbstraction
private organizationApiService: OrganizationApiServiceAbstraction,
private organizationUserService: OrganizationUserService
) {
super(
i18nService,
@ -136,7 +138,7 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
resetRequest.masterPasswordHash = masterPasswordHash;
resetRequest.resetPasswordKey = encryptedKey.encryptedString;
return this.apiService.putOrganizationUserResetPasswordEnrollment(
return this.organizationUserService.putOrganizationUserResetPasswordEnrollment(
this.orgId,
userId,
resetRequest

View File

@ -2,8 +2,8 @@ import { Injector, LOCALE_ID, NgModule } from "@angular/core";
import { AccountApiService as AccountApiServiceAbstraction } from "@bitwarden/common/abstractions/account/account-api.service";
import {
InternalAccountService,
AccountService as AccountServiceAbstraction,
InternalAccountService,
} from "@bitwarden/common/abstractions/account/account.service";
import { AnonymousHubService as AnonymousHubServiceAbstraction } from "@bitwarden/common/abstractions/anonymousHub.service";
import { ApiService as ApiServiceAbstraction } from "@bitwarden/common/abstractions/api.service";
@ -35,6 +35,7 @@ import { LogService } from "@bitwarden/common/abstractions/log.service";
import { LoginService as LoginServiceAbstraction } from "@bitwarden/common/abstractions/login.service";
import { MessagingService as MessagingServiceAbstraction } from "@bitwarden/common/abstractions/messaging.service";
import { NotificationsService as NotificationsServiceAbstraction } from "@bitwarden/common/abstractions/notifications.service";
import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import {
InternalOrganizationService,
@ -45,8 +46,8 @@ import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from "@
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/abstractions/platformUtils.service";
import { PolicyApiServiceAbstraction } from "@bitwarden/common/abstractions/policy/policy-api.service.abstraction";
import {
PolicyService as PolicyServiceAbstraction,
InternalPolicyService,
PolicyService as PolicyServiceAbstraction,
} from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
import { ProviderService as ProviderServiceAbstraction } from "@bitwarden/common/abstractions/provider.service";
import { SearchService as SearchServiceAbstraction } from "@bitwarden/common/abstractions/search.service";
@ -96,6 +97,7 @@ import { FormValidationErrorsService } from "@bitwarden/common/services/formVali
import { KeyConnectorService } from "@bitwarden/common/services/keyConnector.service";
import { LoginService } from "@bitwarden/common/services/login.service";
import { NotificationsService } from "@bitwarden/common/services/notifications.service";
import { OrganizationUserServiceImplementation } from "@bitwarden/common/services/organization-user/organization-user.service.implementation";
import { OrganizationApiService } from "@bitwarden/common/services/organization/organization-api.service";
import { OrganizationService } from "@bitwarden/common/services/organization/organization.service";
import { PasswordGenerationService } from "@bitwarden/common/services/passwordGeneration.service";
@ -126,16 +128,16 @@ import { UnauthGuard } from "../guards/unauth.guard";
import { BroadcasterService } from "./broadcaster.service";
import {
WINDOW,
LOCALES_DIRECTORY,
LOCKED_CALLBACK,
LOG_MAC_FAILURES,
LOGOUT_CALLBACK,
MEMORY_STORAGE,
SECURE_STORAGE,
STATE_FACTORY,
STATE_SERVICE_USE_CACHE,
LOGOUT_CALLBACK,
LOCKED_CALLBACK,
LOCALES_DIRECTORY,
SYSTEM_LANGUAGE,
LOG_MAC_FAILURES,
WINDOW,
} from "./injection-tokens";
import { ModalService } from "./modal.service";
import { PasswordRepromptService } from "./passwordReprompt.service";
@ -539,6 +541,11 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
provide: InternalOrganizationService,
useExisting: OrganizationServiceAbstraction,
},
{
provide: OrganizationUserService,
useClass: OrganizationUserServiceImplementation,
deps: [ApiServiceAbstraction],
},
{
provide: ProviderServiceAbstraction,
useClass: ProviderService,

View File

@ -34,15 +34,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";
@ -117,13 +108,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";
@ -136,8 +120,8 @@ import {
import { ProviderUserBulkPublicKeyResponse } from "../models/response/provider/provider-user-bulk-public-key.response";
import { ProviderUserBulkResponse } from "../models/response/provider/provider-user-bulk.response";
import {
ProviderUserUserDetailsResponse,
ProviderUserResponse,
ProviderUserUserDetailsResponse,
} from "../models/response/provider/provider-user.response";
import { ProviderResponse } from "../models/response/provider/provider.response";
import { SelectionReadOnlyResponse } from "../models/response/selection-read-only.response";
@ -156,8 +140,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";
@ -355,82 +339,6 @@ export abstract class ApiService {
deleteGroup: (organizationId: string, id: string) => Promise<any>;
deleteGroupUser: (organizationId: string, id: string, organizationUserId: string) => Promise<any>;
getOrganizationUser: (
organizationId: string,
id: string
) => Promise<OrganizationUserDetailsResponse>;
getOrganizationUserGroups: (organizationId: string, id: string) => Promise<string[]>;
getOrganizationUsers: (
organizationId: string
) => Promise<ListResponse<OrganizationUserUserDetailsResponse>>;
getOrganizationUserResetPasswordDetails: (
organizationId: string,
id: string
) => Promise<OrganizationUserResetPasswordDetailsReponse>;
postOrganizationUserInvite: (
organizationId: string,
request: OrganizationUserInviteRequest
) => Promise<any>;
postOrganizationUserReinvite: (organizationId: string, id: string) => Promise<any>;
postManyOrganizationUserReinvite: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
postOrganizationUserAccept: (
organizationId: string,
id: string,
request: OrganizationUserAcceptRequest
) => Promise<any>;
postOrganizationUserConfirm: (
organizationId: string,
id: string,
request: OrganizationUserConfirmRequest
) => Promise<any>;
postOrganizationUsersPublicKey: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>>;
postOrganizationUserBulkConfirm: (
organizationId: string,
request: OrganizationUserBulkConfirmRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
putOrganizationUser: (
organizationId: string,
id: string,
request: OrganizationUserUpdateRequest
) => Promise<any>;
putOrganizationUserGroups: (
organizationId: string,
id: string,
request: OrganizationUserUpdateGroupsRequest
) => Promise<any>;
putOrganizationUserResetPasswordEnrollment: (
organizationId: string,
userId: string,
request: OrganizationUserResetPasswordEnrollmentRequest
) => Promise<void>;
putOrganizationUserResetPassword: (
organizationId: string,
id: string,
request: OrganizationUserResetPasswordRequest
) => Promise<any>;
deleteOrganizationUser: (organizationId: string, id: string) => Promise<any>;
deleteManyOrganizationUsers: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
revokeOrganizationUser: (organizationId: string, id: string) => Promise<any>;
revokeManyOrganizationUsers: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
restoreOrganizationUser: (organizationId: string, id: string) => Promise<any>;
restoreManyOrganizationUsers: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
getSync: () => Promise<SyncResponse>;
postPublicImportDirectory: (request: OrganizationImportRequest) => Promise<any>;

View File

@ -0,0 +1,233 @@
import { ListResponse } from "../../models/response/list.response";
import {
OrganizationUserAcceptRequest,
OrganizationUserBulkConfirmRequest,
OrganizationUserConfirmRequest,
OrganizationUserInviteRequest,
OrganizationUserResetPasswordEnrollmentRequest,
OrganizationUserResetPasswordRequest,
OrganizationUserUpdateGroupsRequest,
OrganizationUserUpdateRequest,
} from "./requests";
import {
OrganizationUserBulkPublicKeyResponse,
OrganizationUserBulkResponse,
OrganizationUserDetailsResponse,
OrganizationUserResetPasswordDetailsReponse,
OrganizationUserUserDetailsResponse,
} from "./responses";
/**
* Service for interacting with Organization Users via the API
*/
export abstract class OrganizationUserService {
/**
* Retrieve a single organization user by Id
* @param organizationId - Identifier for the user's organization
* @param id - Organization user identifier
*/
abstract getOrganizationUser(
organizationId: string,
id: string
): Promise<OrganizationUserDetailsResponse>;
/**
* Retrieve a list of groups Ids the specified organization user belongs to
* @param organizationId - Identifier for the user's organization
* @param id - Organization user identifier
*/
abstract getOrganizationUserGroups(organizationId: string, id: string): Promise<string[]>;
/**
* Retrieve a list of all users that belong to the specified organization
* @param organizationId - Identifier for the organization
*/
abstract getAllUsers(
organizationId: string
): Promise<ListResponse<OrganizationUserUserDetailsResponse>>;
/**
* Retrieve reset password details for the specified organization user
* @param organizationId - Identifier for the user's organization
* @param id - Organization user identifier
*/
abstract getOrganizationUserResetPasswordDetails(
organizationId: string,
id: string
): Promise<OrganizationUserResetPasswordDetailsReponse>;
/**
* Create new organization user invite(s) for the specified organization
* @param organizationId - Identifier for the organization
* @param request - New user invitation request details
*/
abstract postOrganizationUserInvite(
organizationId: string,
request: OrganizationUserInviteRequest
): Promise<void>;
/**
* Re-invite the specified organization user
* @param organizationId - Identifier for the user's organization
* @param id - Organization user identifier
*/
abstract postOrganizationUserReinvite(organizationId: string, id: string): Promise<any>;
/**
* Re-invite many organization users for the specified organization
* @param organizationId - Identifier for the organization
* @param ids - A list of organization user identifiers
* @return List of user ids, including both those that were successfully re-invited and those that had an error
*/
abstract postManyOrganizationUserReinvite(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>>;
/**
* Accept an organization user invitation
* @param organizationId - Identifier for the organization to accept
* @param id - Organization user identifier
* @param request - Request details for accepting the invitation
*/
abstract postOrganizationUserAccept(
organizationId: string,
id: string,
request: OrganizationUserAcceptRequest
): Promise<void>;
/**
* Confirm an organization user that has accepted their invitation
* @param organizationId - Identifier for the organization to confirm
* @param id - Organization user identifier
* @param request - Request details for confirming the user
*/
abstract postOrganizationUserConfirm(
organizationId: string,
id: string,
request: OrganizationUserConfirmRequest
): Promise<void>;
/**
* Retrieve a list of the specified users' public keys
* @param organizationId - Identifier for the organization to accept
* @param ids - A list of organization user identifiers to retrieve public keys for
*/
abstract postOrganizationUsersPublicKey(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>>;
/**
* Confirm many organization users that have accepted their invitations
* @param organizationId - Identifier for the organization to confirm users
* @param request - Bulk request details for confirming the user
*/
abstract postOrganizationUserBulkConfirm(
organizationId: string,
request: OrganizationUserBulkConfirmRequest
): Promise<ListResponse<OrganizationUserBulkResponse>>;
/**
* Update an organization users
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
* @param request - Request details for updating the user
*/
abstract putOrganizationUser(
organizationId: string,
id: string,
request: OrganizationUserUpdateRequest
): Promise<void>;
/**
* Update an organization user's groups
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
* @param groupIds - List of group ids to associate the user with
*/
abstract putOrganizationUserGroups(
organizationId: string,
id: string,
groupIds: OrganizationUserUpdateGroupsRequest
): Promise<void>;
/**
* Update an organization user's reset password enrollment
* @param organizationId - Identifier for the organization the user belongs to
* @param userId - Organization user identifier
* @param request - Reset password enrollment details
*/
abstract putOrganizationUserResetPasswordEnrollment(
organizationId: string,
userId: string,
request: OrganizationUserResetPasswordEnrollmentRequest
): Promise<void>;
/**
* Reset an organization user's password
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
* @param request - Reset password details
*/
abstract putOrganizationUserResetPassword(
organizationId: string,
id: string,
request: OrganizationUserResetPasswordRequest
): Promise<void>;
/**
* Delete an organization user
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
*/
abstract deleteOrganizationUser(organizationId: string, id: string): Promise<void>;
/**
* Delete many organization users
* @param organizationId - Identifier for the organization the users belongs to
* @param ids - List of organization user identifiers to delete
* @return List of user ids, including both those that were successfully deleted and those that had an error
*/
abstract deleteManyOrganizationUsers(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>>;
/**
* Revoke an organization user's access to the organization
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
*/
abstract revokeOrganizationUser(organizationId: string, id: string): Promise<void>;
/**
* Revoke many organization users' access to the organization
* @param organizationId - Identifier for the organization the users belongs to
* @param ids - List of organization user identifiers to revoke
* @return List of user ids, including both those that were successfully revoked and those that had an error
*/
abstract revokeManyOrganizationUsers(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>>;
/**
* Restore an organization user's access to the organization
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
*/
abstract restoreOrganizationUser(organizationId: string, id: string): Promise<void>;
/**
* Restore many organization users' access to the organization
* @param organizationId - Identifier for the organization the users belongs to
* @param ids - List of organization user identifiers to restore
* @return List of user ids, including both those that were successfully restored and those that had an error
*/
abstract restoreManyOrganizationUsers(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>>;
}

View File

@ -0,0 +1,8 @@
export * from "./organization-user-accept.request";
export * from "./organization-user-bulk-confirm.request";
export * from "./organization-user-confirm.request";
export * from "./organization-user-invite.request";
export * from "./organization-user-reset-password.request";
export * from "./organization-user-reset-password-enrollment.request";
export * from "./organization-user-update.request";
export * from "./organization-user-update-groups.request";

View File

@ -0,0 +1,11 @@
import { OrganizationUserType } from "../../../enums/organizationUserType";
import { PermissionsApi } from "../../../models/api/permissions.api";
import { SelectionReadOnlyRequest } from "../../../models/request/selection-read-only.request";
export class OrganizationUserInviteRequest {
emails: string[] = [];
type: OrganizationUserType;
accessAll: boolean;
collections: SelectionReadOnlyRequest[] = [];
permissions: PermissionsApi;
}

View File

@ -1,4 +1,4 @@
import { SecretVerificationRequest } from "./secret-verification.request";
import { SecretVerificationRequest } from "../../../models/request/secret-verification.request";
export class OrganizationUserResetPasswordEnrollmentRequest extends SecretVerificationRequest {
resetPasswordKey: string;

View File

@ -0,0 +1,10 @@
import { OrganizationUserType } from "../../../enums/organizationUserType";
import { PermissionsApi } from "../../../models/api/permissions.api";
import { SelectionReadOnlyRequest } from "../../../models/request/selection-read-only.request";
export class OrganizationUserUpdateRequest {
type: OrganizationUserType;
accessAll: boolean;
collections: SelectionReadOnlyRequest[] = [];
permissions: PermissionsApi;
}

View File

@ -0,0 +1,3 @@
export * from "./organization-user.response";
export * from "./organization-user-bulk.response";
export * from "./organization-user-bulk-public-key.response";

View File

@ -1,4 +1,4 @@
import { BaseResponse } from "./base.response";
import { BaseResponse } from "../../../models/response/base.response";
export class OrganizationUserBulkPublicKeyResponse extends BaseResponse {
id: string;

View File

@ -1,4 +1,4 @@
import { BaseResponse } from "./base.response";
import { BaseResponse } from "../../../models/response/base.response";
export class OrganizationUserBulkResponse extends BaseResponse {
id: string;

View File

@ -1,10 +1,9 @@
import { KdfType } from "../../enums/kdfType";
import { OrganizationUserStatusType } from "../../enums/organizationUserStatusType";
import { OrganizationUserType } from "../../enums/organizationUserType";
import { PermissionsApi } from "../api/permissions.api";
import { BaseResponse } from "./base.response";
import { SelectionReadOnlyResponse } from "./selection-read-only.response";
import { KdfType } from "../../../enums/kdfType";
import { OrganizationUserStatusType } from "../../../enums/organizationUserStatusType";
import { OrganizationUserType } from "../../../enums/organizationUserType";
import { PermissionsApi } from "../../../models/api/permissions.api";
import { BaseResponse } from "../../../models/response/base.response";
import { SelectionReadOnlyResponse } from "../../../models/response/selection-read-only.response";
export class OrganizationUserResponse extends BaseResponse {
id: string;

View File

@ -1,12 +0,0 @@
import { OrganizationUserType } from "../../enums/organizationUserType";
import { PermissionsApi } from "../api/permissions.api";
import { SelectionReadOnlyRequest } from "./selection-read-only.request";
export class OrganizationUserInviteRequest {
emails: string[] = [];
type: OrganizationUserType;
accessAll: boolean;
collections: SelectionReadOnlyRequest[] = [];
permissions: PermissionsApi;
}

View File

@ -1,11 +0,0 @@
import { OrganizationUserType } from "../../enums/organizationUserType";
import { PermissionsApi } from "../api/permissions.api";
import { SelectionReadOnlyRequest } from "./selection-read-only.request";
export class OrganizationUserUpdateRequest {
type: OrganizationUserType;
accessAll: boolean;
collections: SelectionReadOnlyRequest[] = [];
permissions: PermissionsApi;
}

View File

@ -1,4 +1,4 @@
import { OrganizationUserResetPasswordRequest } from "./organization-user-reset-password.request";
import { OrganizationUserResetPasswordRequest } from "../../abstractions/organization-user/requests";
export class UpdateTempPasswordRequest extends OrganizationUserResetPasswordRequest {
masterPasswordHint: string;

View File

@ -1,3 +1,3 @@
import { OrganizationUserBulkPublicKeyResponse } from "../organization-user-bulk-public-key.response";
import { OrganizationUserBulkPublicKeyResponse } from "../../../abstractions/organization-user/responses";
export class ProviderUserBulkPublicKeyResponse extends OrganizationUserBulkPublicKeyResponse {}

View File

@ -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>> {

View File

@ -0,0 +1,299 @@
import { ApiService } from "../../abstractions/api.service";
import { OrganizationUserService } from "../../abstractions/organization-user/organization-user.service";
import {
OrganizationUserAcceptRequest,
OrganizationUserBulkConfirmRequest,
OrganizationUserConfirmRequest,
OrganizationUserInviteRequest,
OrganizationUserResetPasswordEnrollmentRequest,
OrganizationUserResetPasswordRequest,
OrganizationUserUpdateGroupsRequest,
OrganizationUserUpdateRequest,
} from "../../abstractions/organization-user/requests";
import {
OrganizationUserBulkPublicKeyResponse,
OrganizationUserBulkResponse,
OrganizationUserDetailsResponse,
OrganizationUserResetPasswordDetailsReponse,
OrganizationUserUserDetailsResponse,
} from "../../abstractions/organization-user/responses";
import { ListResponse } from "../../models/response/list.response";
import { OrganizationUserBulkRequest } from "./requests";
export class OrganizationUserServiceImplementation implements OrganizationUserService {
constructor(private apiService: ApiService) {}
async getOrganizationUser(
organizationId: string,
id: string
): Promise<OrganizationUserDetailsResponse> {
const r = await this.apiService.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.apiService.send(
"GET",
"/organizations/" + organizationId + "/users/" + id + "/groups",
null,
true,
true
);
return r;
}
async getAllUsers(
organizationId: string
): Promise<ListResponse<OrganizationUserUserDetailsResponse>> {
const r = await this.apiService.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.apiService.send(
"GET",
"/organizations/" + organizationId + "/users/" + id + "/reset-password-details",
null,
true,
true
);
return new OrganizationUserResetPasswordDetailsReponse(r);
}
postOrganizationUserInvite(
organizationId: string,
request: OrganizationUserInviteRequest
): Promise<void> {
return this.apiService.send(
"POST",
"/organizations/" + organizationId + "/users/invite",
request,
true,
false
);
}
postOrganizationUserReinvite(organizationId: string, id: string): Promise<any> {
return this.apiService.send(
"POST",
"/organizations/" + organizationId + "/users/" + id + "/reinvite",
null,
true,
false
);
}
async postManyOrganizationUserReinvite(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>> {
const r = await this.apiService.send(
"POST",
"/organizations/" + organizationId + "/users/reinvite",
new OrganizationUserBulkRequest(ids),
true,
true
);
return new ListResponse(r, OrganizationUserBulkResponse);
}
postOrganizationUserAccept(
organizationId: string,
id: string,
request: OrganizationUserAcceptRequest
): Promise<void> {
return this.apiService.send(
"POST",
"/organizations/" + organizationId + "/users/" + id + "/accept",
request,
true,
false
);
}
postOrganizationUserConfirm(
organizationId: string,
id: string,
request: OrganizationUserConfirmRequest
): Promise<void> {
return this.apiService.send(
"POST",
"/organizations/" + organizationId + "/users/" + id + "/confirm",
request,
true,
false
);
}
async postOrganizationUsersPublicKey(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>> {
const r = await this.apiService.send(
"POST",
"/organizations/" + organizationId + "/users/public-keys",
new OrganizationUserBulkRequest(ids),
true,
true
);
return new ListResponse(r, OrganizationUserBulkPublicKeyResponse);
}
async postOrganizationUserBulkConfirm(
organizationId: string,
request: OrganizationUserBulkConfirmRequest
): Promise<ListResponse<OrganizationUserBulkResponse>> {
const r = await this.apiService.send(
"POST",
"/organizations/" + organizationId + "/users/confirm",
request,
true,
true
);
return new ListResponse(r, OrganizationUserBulkResponse);
}
putOrganizationUser(
organizationId: string,
id: string,
request: OrganizationUserUpdateRequest
): Promise<void> {
return this.apiService.send(
"PUT",
"/organizations/" + organizationId + "/users/" + id,
request,
true,
false
);
}
putOrganizationUserGroups(
organizationId: string,
id: string,
request: OrganizationUserUpdateGroupsRequest
): Promise<void> {
return this.apiService.send(
"PUT",
"/organizations/" + organizationId + "/users/" + id + "/groups",
request,
true,
false
);
}
putOrganizationUserResetPasswordEnrollment(
organizationId: string,
userId: string,
request: OrganizationUserResetPasswordEnrollmentRequest
): Promise<void> {
return this.apiService.send(
"PUT",
"/organizations/" + organizationId + "/users/" + userId + "/reset-password-enrollment",
request,
true,
false
);
}
putOrganizationUserResetPassword(
organizationId: string,
id: string,
request: OrganizationUserResetPasswordRequest
): Promise<void> {
return this.apiService.send(
"PUT",
"/organizations/" + organizationId + "/users/" + id + "/reset-password",
request,
true,
false
);
}
deleteOrganizationUser(organizationId: string, id: string): Promise<any> {
return this.apiService.send(
"DELETE",
"/organizations/" + organizationId + "/users/" + id,
null,
true,
false
);
}
async deleteManyOrganizationUsers(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>> {
const r = await this.apiService.send(
"DELETE",
"/organizations/" + organizationId + "/users",
new OrganizationUserBulkRequest(ids),
true,
true
);
return new ListResponse(r, OrganizationUserBulkResponse);
}
revokeOrganizationUser(organizationId: string, id: string): Promise<void> {
return this.apiService.send(
"PUT",
"/organizations/" + organizationId + "/users/" + id + "/revoke",
null,
true,
false
);
}
async revokeManyOrganizationUsers(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>> {
const r = await this.apiService.send(
"PUT",
"/organizations/" + organizationId + "/users/revoke",
new OrganizationUserBulkRequest(ids),
true,
true
);
return new ListResponse(r, OrganizationUserBulkResponse);
}
restoreOrganizationUser(organizationId: string, id: string): Promise<void> {
return this.apiService.send(
"PUT",
"/organizations/" + organizationId + "/users/" + id + "/restore",
null,
true,
false
);
}
async restoreManyOrganizationUsers(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>> {
const r = await this.apiService.send(
"PUT",
"/organizations/" + organizationId + "/users/restore",
new OrganizationUserBulkRequest(ids),
true,
true
);
return new ListResponse(r, OrganizationUserBulkResponse);
}
}

View File

@ -0,0 +1 @@
export * from "./organization-user-bulk.request";