Skip to content

Commit

Permalink
use getUserId and getOrganizationById (#13017)
Browse files Browse the repository at this point in the history
  • Loading branch information
BTreston authored Jan 22, 2025
1 parent a949f79 commit f5744ed
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions apps/cli/src/tools/import.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
// @ts-strict-ignore
import { OptionValues } from "commander";
import * as inquirer from "inquirer";
import { firstValueFrom, map } from "rxjs";
import { firstValueFrom } from "rxjs";

import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import {
OrganizationService,
getOrganizationById,
} from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { ImportServiceAbstraction, ImportType } from "@bitwarden/importer/core";

Expand All @@ -24,16 +28,12 @@ export class ImportCommand {
async run(format: ImportType, filepath: string, options: OptionValues): Promise<Response> {
const organizationId = options.organizationid;
if (organizationId != null) {
const userId = await firstValueFrom(
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
);
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
if (!userId) {
return Response.badRequest("No user found.");
}
const organization = await firstValueFrom(
this.organizationService
.organizations$(userId)
.pipe(map((organizations) => organizations.find((o) => o.id === organizationId))),
this.organizationService.organizations$(userId).pipe(getOrganizationById(organizationId)),
);

if (organization == null) {
Expand Down

0 comments on commit f5744ed

Please sign in to comment.