Skip to content

Commit

Permalink
fix: checkPermission tolerates context without userHubSettings (#1416)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbouwman authored Feb 16, 2024
1 parent 128a1d2 commit f9e7669
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/common/src/permissions/checkPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function checkPermission(

// We also check the context.userHubSettings.preview array
// which can also be used to enable features.
if (context.userHubSettings.preview) {
if (context.userHubSettings?.preview) {
const preview = getWithDefault(
context,
"userHubSettings.preview",
Expand Down
6 changes: 6 additions & 0 deletions packages/common/test/permissions/checkPermission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,5 +418,11 @@ describe("checkPermission:", () => {

expect(chk.access).toBe(true);
});
it("tolerates context without userHubSettings", () => {
const localCtx = cloneObject(premiumCtxMgr.context);
delete localCtx.userHubSettings;
const chk = checkPermission("hub:feature:workspace", localCtx);
expect(chk.access).toBe(false);
});
});
});

0 comments on commit f9e7669

Please sign in to comment.