How can I check if the current login user has specific roles and he is the manager of a group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2023 03:14 AM
How can I make sure that only users with 'local_manager' role or user that is currently currently trying to edit the group members is the manager of that group will be able to edit?
I tried to user this advance acl both on write and create but its not working.
if (gs.hasRole('local_manager')) {
answer = true;
} else if (current.group.manager == gs.getUserID()) {
answer = true;
}
else {
answer = false;
}
I
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2023 03:47 AM
Hi @Alon Grod ,
Please try below script:
Make ACL on "Create" operation on table level & write below script in Advance section.
if (gs.getUser().hasRole('local_manager') && (gs.getUser().isMemberOf("Sys Id of your group")))
answer = true;
else
answer = false;
OR
if (gs.getUser().hasRole('local_manager') && (gs.getUser().isMemberOf(gs.getProperty("Group")))) // Group is the sys_Property name
answer = true;
else
answer = false;
Please try above once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2023 03:50 AM
@abirakundu23 but the group should be dynamic. its not always the same group. if he is trying to edit a group members of a group that he is the manager (manager field on sys_user_group table), then it should be fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2023 03:57 AM
Hi @Alon Grod!
Check first if your code is executed, put before "if" a log, if the code doesn't work, post a picture of the acl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2023 04:23 AM
@Alex Tod1 @abirakundu23
I have this acl (both write and create) on sys_user_grmember. but when I impersonate someone that he is the manager of the group he still cant edit group members. The 'Edit' Button is not shown and when I click on New it says that the user is not autorized.