mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-07-24 13:02:16 +00:00
Add check for users to delete function (#104)
* add check for users to delete function * fix typo * fix active admin check --------- Co-authored-by: eglehelms <e.helms@cognigy.com>
This commit is contained in:
@@ -424,7 +424,8 @@ router.delete('/:user_sid', async(req, res) => {
|
||||
const user = await User.retrieve(user_sid);
|
||||
|
||||
try {
|
||||
if (decodedJwt.scope === 'admin' && activeAdminUsers.length === 1) {
|
||||
if (decodedJwt.scope === 'admin' && !user.account_sid && !user.service_provider_sid &&
|
||||
activeAdminUsers.length === 1) {
|
||||
throw new Error('cannot delete this admin user - there are no other active admin users');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user