mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
[PS-1841] Fix org-* commands for CLI (#4013)
* Add getFromState method * Added a method for CLI to get an org from state * Converted all CLI calls to `.get()` * Used `.getFromState` instead of `.get` * Deprecate getFromState method
This commit is contained in:
@@ -75,6 +75,11 @@ export abstract class OrganizationService {
|
||||
get: (id: string) => Organization;
|
||||
getByIdentifier: (identifier: string) => Organization;
|
||||
getAll: (userId?: string) => Promise<Organization[]>;
|
||||
/**
|
||||
* @deprecated For the CLI only
|
||||
* @param id id of the organization
|
||||
*/
|
||||
getFromState: (id: string) => Promise<Organization>;
|
||||
canManageSponsorships: () => Promise<boolean>;
|
||||
hasOrganizations: () => boolean;
|
||||
}
|
||||
|
||||
@@ -101,6 +101,20 @@ export class OrganizationService implements OrganizationServiceAbstraction {
|
||||
return organizations.find((organization) => organization.id === id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated For the CLI only
|
||||
* @param id id of the organization
|
||||
*/
|
||||
async getFromState(id: string): Promise<Organization> {
|
||||
const organizationsMap = await this.stateService.getOrganizations();
|
||||
const organization = organizationsMap[id];
|
||||
if (organization == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Organization(organization);
|
||||
}
|
||||
|
||||
getByIdentifier(identifier: string): Organization {
|
||||
const organizations = this._organizations.getValue();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user