Skip to content

Commit

Permalink
Merge pull request #2281 from connortechnology/fix_2279_delete_camera…
Browse files Browse the repository at this point in the history
…_through_api

Fix 2279 delete camera through api
  • Loading branch information
knight-of-ni committed Oct 30, 2018
2 parents 3906103 + 9a2d58a commit 073193e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions web/api/app/Controller/MonitorsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ public function delete($id = null) {
if ( !$this->Monitor->exists() ) {
throw new NotFoundException(__('Invalid monitor'));
}
if ( $this->Session->Read('systemPermission') != 'Edit' ) {
throw new UnauthorizedException(__('Insufficient privileges'));
global $user;
$canEdit = (!$user) || ($user['System'] == 'Edit');
if ( !$canEdit ) {
throw new UnauthorizedException(__('Insufficient privileges'));
return;
}
$this->request->allowMethod('post', 'delete');
Expand Down
5 changes: 3 additions & 2 deletions web/api/app/Controller/StatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ public function add() {

if ($this->request->is('post')) {

if ($this->Session->Read('systemPermission') != 'Edit')
{
global $user;
$canEdit = (!$user) || ($user['System'] == 'Edit');
if ( !$canEdit ) {
throw new UnauthorizedException(__('Insufficient privileges'));
return;
}
Expand Down

0 comments on commit 073193e

Please sign in to comment.