Skip to content

Commit

Permalink
Improve SOR handling over API (NOJIRA)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Nov 25, 2018
1 parent 66d7f96 commit f4dbca7
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/src/Controller/TierApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,16 +547,27 @@ public function isAuthorized(Array $user) {

// Authorization is as follows:

// (0) Make sure the Matchgrid is active.
// (0) Make sure the Matchgrid is active and the requested SOR exists.

if(!$this->cur_mg) {
Log::write('debug', "TierApiController::isAuthorized() Requested matchgrid " . $mgid . " not found");
return false;
throw new \Cake\Http\Exception\ForbiddenException("Requested matchgrid " . $mgid . " not found");
}

if($this->cur_mg->status != StatusEnum::Active) {
Log::write('debug', "TierApiController::isAuthorized() Requested matchgrid " . $mgid . " is not Active");
return false;
throw new \Cake\Http\Exception\ForbiddenException("Requested matchgrid " . $mgid . " is not Active");
}

if($sor && $mgid) {
$this->loadModel('SystemsOfRecord');

$count = $this->SystemsOfRecord->find()->where(['matchgrid_id' => $mgid, 'label' => $sor])->count();

if($count == 0) {
Log::write('debug', "TierApiController::isAuthorized() Requested SOR " . $sor . " not found");
throw new \Cake\Http\Exception\ForbiddenException("Requested SOR " . $sor . " not found");
}
}

// (1) A Platform API user ($user['matchgrid_id'] is NULL) may perform any action.
Expand Down

0 comments on commit f4dbca7

Please sign in to comment.