1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +01:00

Output user-specific associations for collections in the CLI (#10154)

Collection management permissions can be set for a group or a specific
user. Currently the CLI only outputs group associations when it displays
collection configuration information. This can cause bugs when piping
commands together.

This commit ensures that `user` associations also get output. In all
cases this data was already available and just needed to be added to a
response model.
This commit is contained in:
Addison Beck 2024-07-18 11:31:54 -04:00 committed by GitHub
parent 577a3a720a
commit 3bfa024b87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 4 deletions

View File

@ -5,10 +5,12 @@ import { SelectionReadOnly } from "../selection-read-only";
export class OrganizationCollectionResponse extends CollectionResponse {
groups: SelectionReadOnly[];
users: SelectionReadOnly[];
constructor(o: CollectionView, groups: SelectionReadOnly[]) {
constructor(o: CollectionView, groups: SelectionReadOnly[], users: SelectionReadOnly[]) {
super(o);
this.object = "org-collection";
this.groups = groups;
this.users = users;
}
}

View File

@ -184,7 +184,7 @@ export class EditCommand {
const response = await this.apiService.putCollection(req.organizationId, id, request);
const view = CollectionExport.toView(req);
view.id = response.id;
const res = new OrganizationCollectionResponse(view, groups);
const res = new OrganizationCollectionResponse(view, groups, users);
return Response.success(res);
} catch (e) {
return Response.error(e);

View File

@ -456,7 +456,13 @@ export class GetCommand extends DownloadCommand {
: response.groups.map(
(g) => new SelectionReadOnly(g.id, g.readOnly, g.hidePasswords, g.manage),
);
const res = new OrganizationCollectionResponse(decCollection, groups);
const users =
response.users == null
? null
: response.users.map(
(g) => new SelectionReadOnly(g.id, g.readOnly, g.hidePasswords, g.manage),
);
const res = new OrganizationCollectionResponse(decCollection, groups, users);
return Response.success(res);
} catch (e) {
return Response.error(e);

View File

@ -208,7 +208,7 @@ export class CreateCommand {
const response = await this.apiService.postCollection(req.organizationId, request);
const view = CollectionExport.toView(req);
view.id = response.id;
const res = new OrganizationCollectionResponse(view, groups);
const res = new OrganizationCollectionResponse(view, groups, users);
return Response.success(res);
} catch (e) {
return Response.error(e);