Skip to content

Commit 658803b

Browse files
committed
IAM | Account Server - Block account deletion in case the account has users
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
1 parent d449491 commit 658803b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/server/system_services/account_server.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,17 @@ function _verify_can_delete_account(req, account_to_delete) {
11791179
throw new RpcError('FORBIDDEN', 'Cannot delete account that is owner of buckets');
11801180
}
11811181
}
1182+
if (account_to_delete.owner === undefined) {
1183+
const has_iam_users = _.some(system_store.data.accounts, function(account) {
1184+
const owner_account_id = account_util.get_owner_account_id(account);
1185+
// Check IAM user owner is same as account_to_delete id
1186+
return owner_account_id === account_to_delete._id.toString();
1187+
});
1188+
if (has_iam_users) {
1189+
dbg.log2('account', account_to_delete.name.unwrap(), 'account has users');
1190+
throw new RpcError('FORBIDDEN', 'Cannot delete account that is owner of IAM users');
1191+
}
1192+
}
11821193
}
11831194

11841195
/**

0 commit comments

Comments
 (0)