Skip to content

Commit e1096de

Browse files
committed
fixed: when updating a user permission by DELETING a user from a certain role, it drops ALL the users. Also if you add a user to a role it will still keep the role on previously added users
1 parent 08dc5b6 commit e1096de

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

src/extensions/rbac/RBACManagementModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export const RBACManagementModal = ({ open, handleClose, currentRole, createNoti
8080

8181
const handleSave = async () => {
8282
createNotification('Updating', `Access for role '${currentRole}' is being updated, please wait...`);
83-
console.log(selectedUsers);
8483
updateUsers(
8584
driver,
8685
currentRole,

src/extensions/rbac/RBACUtils.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -265,34 +265,36 @@ export async function updateUsers(driver, currentRole, allUsers, selectedUsers,
265265
`REVOKE ROLE ${currentRole} FROM ${escapedAllUsers}`,
266266
{},
267267
1000,
268-
(status) => {
268+
async (status) => {
269269
globalStatus = status;
270+
if (globalStatus == QueryStatus.NO_DATA || globalStatus == QueryStatus.COMPLETE) {
271+
// TODO: Neo4j is very slow in updating after the previous query, even though it is technically a finished query.
272+
// We build in an artificial delay... This must be improved the future.
273+
setTimeout(async () => {
274+
if (selectedUsers.length > 0) {
275+
const escapedSelectedUsers = selectedUsers.map((user) => `\`${user}\``).join(',');
276+
await runCypherQuery(
277+
driver,
278+
'system',
279+
`GRANT ROLE ${currentRole} TO ${escapedSelectedUsers};`,
280+
{},
281+
1000,
282+
(status) => {
283+
if (status == QueryStatus.NO_DATA || QueryStatus.COMPLETE) {
284+
onSuccess();
285+
}
286+
}
287+
);
288+
} else {
289+
onSuccess();
290+
}
291+
}, 2000);
292+
}
270293
},
271294
(records) => {
272295
if (records && records[0] && records[0].error) {
273296
onFail(records[0].error);
274297
}
275298
}
276299
);
277-
if (globalStatus == QueryStatus.NO_DATA || globalStatus == QueryStatus.COMPLETE) {
278-
// TODO: Neo4j is very slow in updating after the previous query, even though it is technically a finished query.
279-
// We build in an artificial delay...
280-
if (selectedUsers.length > 0) {
281-
const escapedSelectedUsers = selectedUsers.map((user) => `\`${user}\``).join(',');
282-
await runCypherQuery(
283-
driver,
284-
'system',
285-
`GRANT ROLE ${currentRole} TO ${escapedSelectedUsers}`,
286-
{},
287-
1000,
288-
(status) => {
289-
if (status == QueryStatus.NO_DATA || QueryStatus.COMPLETE) {
290-
onSuccess();
291-
}
292-
}
293-
);
294-
} else {
295-
onSuccess();
296-
}
297-
}
298300
}

0 commit comments

Comments
 (0)