Skip to content

Commit

Permalink
updating logic -- api edits for only manager - error correction
Browse files Browse the repository at this point in the history
Signed-off-by: Prakash P S <prakashps@Prakashs-MacBook-Pro.local>
  • Loading branch information
Prakash P S authored and Prakash P S committed Nov 27, 2023
1 parent 0d54907 commit ac4748e
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/athena/libs/permissions_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,28 @@ module.exports = function (logger, ev, t) {
if (!email) {
input_errors.push('uuid does not exist: ' + encodeURI(uuid));
} else {
let admin_count = 0;
for (let user in settings_doc.access_list) {
if (user.roles.includes('manager'))
if (settings_doc.access_list[email].roles.includes('manager') && !lc_roles.includes('manager'))
{
let admin_count = 0;
for (let user in settings_doc.access_list) {
if (user.roles.includes('manager'))
{
admin_count = admin_count + 1;
}
}
if (admin_count < 2)
{
admin_count = admin_count + 1;
input_errors.push('[only manager] as you are the only manager for this console, you are not allowed to modify your roles');
}
else {
settings_doc.access_list[email].roles = lc_roles; // edit the user object

// build a notification doc
const notice = {
message: 'editing roles for user ' + t.misc.censorEmail(email) + ' - setting ' + lc_roles.join(', '),
};
t.notifications.procrastinate(req, notice);
}
}
if (settings_doc.access_list[email].roles.includes('manager') && admin_count < 2)
{
input_errors.push('[only manager] as you are the only manager for this console, you are not allowed to modify your roles');
}
else
{
Expand Down

0 comments on commit ac4748e

Please sign in to comment.