fix #22766: better API response HTTP code

This commit is contained in:
Eric Seigne
2022-11-26 00:50:45 +01:00
parent 459086b11e
commit 616e2b79ef
6 changed files with 60 additions and 12 deletions

View File

@@ -628,7 +628,18 @@ class Users extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->useraccount->oldcopy = clone $this->useraccount;
return $this->useraccount->delete(DolibarrApiAccess::$user);
if (!$this->useraccount->delete(DolibarrApiAccess::$user)) {
throw new RestException(500);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Ticket deleted'
)
);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore