mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
Import: Migrate input to handle and validate organization (#16920)
* Verify route and input to be a valid organizationId * Optimize canImport check Instead of loading the user and organization again, used the previously loaded organization and check the permission directly * Reset organization in case organizationId is set to undefined --------- Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a860f218bd
commit
b8d55c4db1
@@ -1,5 +1,3 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { firstValueFrom, map } from "rxjs";
|
||||
@@ -11,6 +9,7 @@ import {
|
||||
} 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 { isId, OrganizationId } from "@bitwarden/common/types/guid";
|
||||
import { ImportCollectionServiceAbstraction } from "@bitwarden/importer-core";
|
||||
import { ImportComponent } from "@bitwarden/importer-ui";
|
||||
|
||||
@@ -31,7 +30,7 @@ import { ImportCollectionAdminService } from "./import-collection-admin.service"
|
||||
],
|
||||
})
|
||||
export class OrgImportComponent implements OnInit {
|
||||
protected routeOrgId: string = null;
|
||||
protected routeOrgId: OrganizationId | undefined = undefined;
|
||||
protected loading = false;
|
||||
protected disabled = false;
|
||||
|
||||
@@ -43,7 +42,16 @@ export class OrgImportComponent implements OnInit {
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.routeOrgId = this.route.snapshot.paramMap.get("organizationId");
|
||||
const orgIdParam = this.route.snapshot.paramMap.get("organizationId");
|
||||
if (orgIdParam === undefined) {
|
||||
throw new Error("`organizationId` is a required route parameter");
|
||||
}
|
||||
|
||||
if (!isId<OrganizationId>(orgIdParam)) {
|
||||
throw new Error("Invalid OrganizationId provided in route parameter `organizationId`");
|
||||
}
|
||||
|
||||
this.routeOrgId = orgIdParam;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user