Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"cors": "^2.8.5",
"express": "^4.18.2",
"express-basic-auth": "^1.2.1",
"express-rate-limit": "^7.0.2",
"express-rate-limit": "^7.1.1",
"express-validator": "^7.0.1",
"graphql": "^16.8.1",
"graphql-http": "^1.22.0",
Expand All @@ -41,28 +41,28 @@
"jsonwebtoken": "^9.0.2",
"moment": "^2.29.4",
"mongodb": "^6.1.0",
"mongoose": "^7.5.3",
"pino": "^8.15.3",
"pino-pretty": "^10.2.0",
"mongoose": "^7.6.2",
"pino": "^8.16.0",
"pino-pretty": "^10.2.3",
"swagger-ui-express": "^5.0.0",
"switcher-client": "^3.1.9",
"validator": "^13.11.0"
},
"devDependencies": {
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.0",
"@babel/core": "^7.23.2",
"@babel/node": "^7.22.19",
"@babel/preset-env": "^7.22.20",
"@babel/preset-env": "^7.23.2",
"@babel/register": "^7.22.15",
"babel-jest": "^29.7.0",
"babel-polyfill": "^6.26.0",
"env-cmd": "^10.1.0",
"eslint": "^8.50.0",
"eslint": "^8.51.0",
"jest": "^29.7.0",
"jest-sonar-reporter": "^2.0.0",
"node-notifier": "^10.0.1",
"nodemon": "^3.0.1",
"sinon": "^16.0.0",
"sinon": "^16.1.0",
"supertest": "^6.3.3"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/client/permission-resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function resolvePermission(args, admin) {
return [];
}

const cacheKey = permissionCache.permissionKey(admin._id, args.domain, elements, args.actions, args.router);
const cacheKey = permissionCache.permissionKey(admin._id, args.domain, args.parent, args.actions, args.router);
if (permissionCache.has(cacheKey)) {
return permissionCache.get(cacheKey);
}
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class Cache {
return this.cache.get(key);
}

permissionKey(adminId, domainId, elements, action, router) {
permissionKey(adminId, domainId, parentId, actions, router) {
return JSON.stringify({
adminId: String(adminId),
domainId: String(domainId),
elements: elements.map(element => String(element._id)),
actions: action,
router: router
parentId: String(parentId),
actions,
router
});
}

Expand Down
8 changes: 4 additions & 4 deletions tests/unit-test/cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("Test permissionCache", () => {
const cacheKey = permissionCache.permissionKey(
'adminId',
'domainId',
['element1Id', 'element2Id'],
'parentId',
[ActionTypes.UPDATE, ActionTypes.READ],
RouterTypes.GROUP
);
Expand All @@ -22,7 +22,7 @@ describe("Test permissionCache", () => {
const cacheKey = permissionCache.permissionKey(
'adminId',
'domainId',
['element1Id', 'element2Id'],
'parentId',
[ActionTypes.UPDATE, ActionTypes.READ],
RouterTypes.GROUP
);
Expand All @@ -37,7 +37,7 @@ describe("Test permissionCache", () => {
const cacheKey = permissionCache.permissionKey(
'adminId',
'domainId',
['element1Id', 'element2Id'],
'parentId',
[ActionTypes.UPDATE, ActionTypes.READ],
RouterTypes.GROUP
);
Expand All @@ -52,7 +52,7 @@ describe("Test permissionCache", () => {
const cacheKey = permissionCache.permissionKey(
'adminId',
'domainId',
['element1Id', 'element2Id'],
'parentId',
[ActionTypes.UPDATE, ActionTypes.READ],
RouterTypes.GROUP
);
Expand Down