mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53: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:
@@ -5,6 +5,7 @@ import { ActivatedRoute } from "@angular/router";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { OrganizationApiKeyType } from "@bitwarden/common/enums/organizationApiKeyType";
|
||||
import { OrganizationConnectionType } from "@bitwarden/common/enums/organizationConnectionType";
|
||||
@@ -12,6 +13,7 @@ import { ScimConfigApi } from "@bitwarden/common/models/api/scimConfigApi";
|
||||
import { OrganizationApiKeyRequest } from "@bitwarden/common/models/request/organizationApiKeyRequest";
|
||||
import { OrganizationConnectionRequest } from "@bitwarden/common/models/request/organizationConnectionRequest";
|
||||
import { ScimConfigRequest } from "@bitwarden/common/models/request/scimConfigRequest";
|
||||
import { ApiKeyResponse } from "@bitwarden/common/models/response/apiKeyResponse";
|
||||
import { OrganizationConnectionResponse } from "@bitwarden/common/models/response/organizationConnectionResponse";
|
||||
|
||||
@Component({
|
||||
@@ -22,8 +24,8 @@ export class ScimComponent implements OnInit {
|
||||
loading = true;
|
||||
organizationId: string;
|
||||
existingConnectionId: string;
|
||||
formPromise: Promise<any>;
|
||||
rotatePromise: Promise<any>;
|
||||
formPromise: Promise<OrganizationConnectionResponse<ScimConfigApi>>;
|
||||
rotatePromise: Promise<ApiKeyResponse>;
|
||||
enabled = new FormControl(false);
|
||||
showScimSettings = false;
|
||||
|
||||
@@ -38,7 +40,8 @@ export class ScimComponent implements OnInit {
|
||||
private apiService: ApiService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService,
|
||||
private environmentService: EnvironmentService
|
||||
private environmentService: EnvironmentService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -61,7 +64,7 @@ export class ScimComponent implements OnInit {
|
||||
const apiKeyRequest = new OrganizationApiKeyRequest();
|
||||
apiKeyRequest.type = OrganizationApiKeyType.Scim;
|
||||
apiKeyRequest.masterPasswordHash = "N/A";
|
||||
const apiKeyResponse = await this.apiService.postOrganizationApiKey(
|
||||
const apiKeyResponse = await this.organizationApiService.getOrCreateApiKey(
|
||||
this.organizationId,
|
||||
apiKeyRequest
|
||||
);
|
||||
@@ -91,7 +94,7 @@ export class ScimComponent implements OnInit {
|
||||
request.type = OrganizationApiKeyType.Scim;
|
||||
request.masterPasswordHash = "N/A";
|
||||
|
||||
this.rotatePromise = this.apiService.postOrganizationRotateApiKey(this.organizationId, request);
|
||||
this.rotatePromise = this.organizationApiService.rotateApiKey(this.organizationId, request);
|
||||
|
||||
try {
|
||||
const response = await this.rotatePromise;
|
||||
|
||||
@@ -7,6 +7,7 @@ import { dirtyRequired } from "@bitwarden/angular/validators/dirty.validator";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import {
|
||||
OpenIdConnectRedirectBehavior,
|
||||
@@ -79,7 +80,7 @@ export class SsoComponent implements OnInit {
|
||||
haveTestedKeyConnector = false;
|
||||
organizationId: string;
|
||||
organization: Organization;
|
||||
formPromise: Promise<any>;
|
||||
formPromise: Promise<OrganizationSsoResponse>;
|
||||
|
||||
callbackPath: string;
|
||||
signedOutCallbackPath: string;
|
||||
@@ -147,7 +148,8 @@ export class SsoComponent implements OnInit {
|
||||
private apiService: ApiService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService,
|
||||
private organizationService: OrganizationService
|
||||
private organizationService: OrganizationService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -178,7 +180,7 @@ export class SsoComponent implements OnInit {
|
||||
|
||||
async load() {
|
||||
this.organization = await this.organizationService.get(this.organizationId);
|
||||
const ssoSettings = await this.apiService.getOrganizationSso(this.organizationId);
|
||||
const ssoSettings = await this.organizationApiService.getSso(this.organizationId);
|
||||
this.populateForm(ssoSettings);
|
||||
|
||||
this.callbackPath = ssoSettings.urls.callbackPath;
|
||||
@@ -206,7 +208,7 @@ export class SsoComponent implements OnInit {
|
||||
request.enabled = this.enabled.value;
|
||||
request.data = SsoConfigApi.fromView(this.ssoConfigForm.value as SsoConfigView);
|
||||
|
||||
this.formPromise = this.apiService.postOrganizationSso(this.organizationId, request);
|
||||
this.formPromise = this.organizationApiService.updateSso(this.organizationId, request);
|
||||
|
||||
try {
|
||||
const response = await this.formPromise;
|
||||
|
||||
@@ -8,6 +8,7 @@ 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 { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { ProviderService } from "@bitwarden/common/abstractions/provider.service";
|
||||
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
||||
@@ -32,7 +33,7 @@ const DisallowedPlanTypes = [
|
||||
export class ClientsComponent implements OnInit {
|
||||
@ViewChild("add", { read: ViewContainerRef, static: true }) addModalRef: ViewContainerRef;
|
||||
|
||||
providerId: any;
|
||||
providerId: string;
|
||||
searchText: string;
|
||||
addableOrganizations: Organization[];
|
||||
loading = true;
|
||||
@@ -44,7 +45,7 @@ export class ClientsComponent implements OnInit {
|
||||
|
||||
protected didScroll = false;
|
||||
protected pageSize = 100;
|
||||
protected actionPromise: Promise<any>;
|
||||
protected actionPromise: Promise<unknown>;
|
||||
private pagedClientsCount = 0;
|
||||
|
||||
constructor(
|
||||
@@ -58,7 +59,8 @@ export class ClientsComponent implements OnInit {
|
||||
private webProviderService: WebProviderService,
|
||||
private logService: LogService,
|
||||
private modalService: ModalService,
|
||||
private organizationService: OrganizationService
|
||||
private organizationService: OrganizationService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -82,7 +84,7 @@ export class ClientsComponent implements OnInit {
|
||||
(o) => o.isOwner && o.providerId == null
|
||||
);
|
||||
const allowedOrgsIds = await Promise.all(
|
||||
candidateOrgs.map((o) => this.apiService.getOrganization(o.id))
|
||||
candidateOrgs.map((o) => this.organizationApiService.get(o.id))
|
||||
).then((orgs) =>
|
||||
orgs.filter((o) => !DisallowedPlanTypes.includes(o.planType)).map((o) => o.id)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user