Skip to content

Commit

Permalink
[examiner] Adds permission check when adding examiner to site. (#9188)
Browse files Browse the repository at this point in the history
Permissions are check now before allowing to add examiner to site.
Before this, a user with only the permission Examiner: Add and Certify Examiners - Own Sites was able to add examiners to sites it don't belongs to. Now this feature is only granted to users with the corresponding level of permission.

Fixes #9149
  • Loading branch information
racostas authored Apr 24, 2024
1 parent 7eafeef commit bff9931
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions modules/examiner/php/addexaminer.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ class AddExaminer extends \NDB_Page
$fullName = $values['addName'] ?? '';
$siteID = $values['addSite'] ?? '';

// check for site permissions
$user = \User::singleton();
if (!$user->hasPermission('examiner_multisite')
&& !in_array($siteID, $user->getCenterIDs())
) {
return new \LORIS\Http\Response\JSON\Forbidden(
'Permission denied: You cannot assign examiner to this Site.'
);
};

if ($this->examinerExists($fullName, $siteID)) {
return new \LORIS\Http\Response\JSON\Conflict(
'This examiner already exists.'
Expand Down
10 changes: 8 additions & 2 deletions modules/examiner/php/examiner.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ class Examiner extends \DataFrameworkMenu

$useCertification = ($this->useCertification == 1) ? true : false;

$user = \User::singleton();
if ($user->hasPermission('examiner_multisite')) {
$sites = \Utility::getSiteList(false);
} else {
$sites = $user->getStudySites();
}
return [
'sites' => \Utility::getSiteList(false),
'sites' => $sites,
'radiologists' => $yesNoOptions,
'useCertification' => $useCertification,
'useCertification' => $useCertification,
];

}
Expand Down

0 comments on commit bff9931

Please # to comment.