1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 21:33:27 +00:00

[PS-1093] Move Organization Api Calls (#3243)

* Move organization api calls into seperate service

* Remove unneeded unknown

* Address PR feedback
This commit is contained in:
Justin Baur
2022-08-24 12:33:05 -04:00
committed by GitHub
parent 364d2f311e
commit 7145b13df1
39 changed files with 545 additions and 414 deletions

View File

@@ -4,6 +4,7 @@ import { Router } from "@angular/router";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { KeyConnectorService } from "@bitwarden/common/abstractions/keyConnector.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { SyncService } from "@bitwarden/common/abstractions/sync.service";
@@ -11,7 +12,7 @@ import { Organization } from "@bitwarden/common/models/domain/organization";
@Directive()
export class RemovePasswordComponent implements OnInit {
actionPromise: Promise<any>;
actionPromise: Promise<void | boolean>;
continuing = false;
leaving = false;
@@ -26,7 +27,8 @@ export class RemovePasswordComponent implements OnInit {
private syncService: SyncService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private keyConnectorService: KeyConnectorService
private keyConnectorService: KeyConnectorService,
private organizationApiService: OrganizationApiServiceAbstraction
) {}
async ngOnInit() {
@@ -68,7 +70,7 @@ export class RemovePasswordComponent implements OnInit {
try {
this.leaving = true;
this.actionPromise = this.apiService.postLeaveOrganization(this.organization.id).then(() => {
this.actionPromise = this.organizationApiService.leave(this.organization.id).then(() => {
return this.syncService.fullSync(true);
});
await this.actionPromise;

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 { 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";
import { PolicyApiServiceAbstraction } from "@bitwarden/common/abstractions/policy/policy-api.service.abstraction";
@@ -32,7 +33,7 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
orgId: string;
resetPasswordAutoEnroll = false;
onSuccessfulChangePassword: () => Promise<any>;
onSuccessfulChangePassword: () => Promise<void>;
successRoute = "vault";
constructor(
@@ -47,7 +48,8 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
private apiService: ApiService,
private syncService: SyncService,
private route: ActivatedRoute,
stateService: StateService
stateService: StateService,
private organizationApiService: OrganizationApiServiceAbstraction
) {
super(
i18nService,
@@ -73,7 +75,7 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
// Automatic Enrollment Detection
if (this.identifier != null) {
try {
const response = await this.apiService.getOrganizationAutoEnrollStatus(this.identifier);
const response = await this.organizationApiService.getAutoEnrollStatus(this.identifier);
this.orgId = response.id;
this.resetPasswordAutoEnroll = response.resetPasswordEnabled;
this.enforcedPolicyOptions =
@@ -113,7 +115,7 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
.setPassword(request)
.then(async () => {
await this.onSetPasswordSuccess(key, encKey, keys);
return this.apiService.getOrganizationKeys(this.orgId);
return this.organizationApiService.getKeys(this.orgId);
})
.then(async (response) => {
if (response == null) {

View File

@@ -30,6 +30,7 @@ import { LogService } from "@bitwarden/common/abstractions/log.service";
import { MessagingService as MessagingServiceAbstraction } from "@bitwarden/common/abstractions/messaging.service";
import { NotificationsService as NotificationsServiceAbstraction } from "@bitwarden/common/abstractions/notifications.service";
import { OrganizationService as OrganizationServiceAbstraction } from "@bitwarden/common/abstractions/organization.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { PasswordGenerationService as PasswordGenerationServiceAbstraction } from "@bitwarden/common/abstractions/passwordGeneration.service";
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from "@bitwarden/common/abstractions/passwordReprompt.service";
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/abstractions/platformUtils.service";
@@ -77,6 +78,7 @@ import { FormValidationErrorsService } from "@bitwarden/common/services/formVali
import { KeyConnectorService } from "@bitwarden/common/services/keyConnector.service";
import { NotificationsService } from "@bitwarden/common/services/notifications.service";
import { OrganizationService } from "@bitwarden/common/services/organization.service";
import { OrganizationApiService } from "@bitwarden/common/services/organization/organization-api.service";
import { PasswordGenerationService } from "@bitwarden/common/services/passwordGeneration.service";
import { PolicyApiService } from "@bitwarden/common/services/policy/policy-api.service";
import { PolicyService } from "@bitwarden/common/services/policy/policy.service";
@@ -513,6 +515,11 @@ export const LOG_MAC_FAILURES = new InjectionToken<string>("LOG_MAC_FAILURES");
useClass: UserVerificationApiService,
deps: [ApiServiceAbstraction],
},
{
provide: OrganizationApiServiceAbstraction,
useClass: OrganizationApiService,
deps: [ApiServiceAbstraction],
},
],
})
export class JslibServicesModule {}