mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-10-20 15:24:13 +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:
1 parent
a46c24b3aa
commit
d4f2be3dc1
2 files changed
+12
-3
No files matched your search
@@ -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