fix: [API] Delete organisations by UUID, fixes #4989

pull/5005/head
iglocska 2019-08-14 11:30:11 +02:00
parent 332f4e6c8b
commit 879c564d0c
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 7 additions and 0 deletions

View File

@ -236,6 +236,13 @@ class OrganisationsController extends AppController
if (!$this->request->is('post') && !$this->request->is('delete')) {
throw new MethodNotAllowedException(__('Action not allowed, post or delete request expected.'));
}
if (Validation::uuid($id)) {
$temp = $this->Organisation->find('first', array('recursive' => -1, 'fields' => array('Organisation.id'), 'conditions' => array('Organisation.uuid' => $id)));
if (empty($temp)) {
throw new NotFoundException(__('Invalid organisation'));
}
$id = $temp['Organisation']['id'];
}
$this->Organisation->id = $id;
if (!$this->Organisation->exists()) {
throw new NotFoundException(__('Invalid organisation'));