Skip to content

Commit 7362470

Browse files
authored
Merge pull request #9321 from shirady/iam-block-account-deletion-with-users
IAM | Account Server - Block Account Deletion in Case the Account Has Users
2 parents d449491 + 658803b commit 7362470

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)