Skip to content

Commit

Permalink
fix: make permissions params optional
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Oct 8, 2023
1 parent d2d18a7 commit a42ccd2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/plugins/workspace/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function registerRoutes({
},
{
...others,
...(permissionsInAttributes ? { permissions: convertToACL(permissions) } : {}),
...(permissions.length ? { permissions: convertToACL(permissions) } : {}),
}
);
return res.ok({ body: result });
Expand All @@ -237,6 +237,10 @@ export function registerRoutes({
const { id } = req.params;
const { attributes } = req.body;
const { permissions, ...others } = attributes;
let finalPermissions: WorkspaceRoutePermissionItem[] = [];
if (permissions) {
finalPermissions = Array.isArray(permissions) ? permissions : [permissions];
}

const result = await client.update(
{
Expand All @@ -247,7 +251,7 @@ export function registerRoutes({
id,
{
...others,
...(permissions ? { permissions: convertToACL(permissions) } : {}),
...(finalPermissions.length ? { permissions: convertToACL(finalPermissions) } : {}),
}
);
return res.ok({ body: result });
Expand Down

0 comments on commit a42ccd2

Please sign in to comment.