Skip to content

Commit

Permalink
Fix search display access for non-admin users
Browse files Browse the repository at this point in the history
Non-admin users should be allowed to view any search display that doesn't have permission checks disabled;
for those displays that disable permission checks, non-admins will only be able to view it if embedded in an afform.

Fixes dev/core#2737
  • Loading branch information
colemanw committed Aug 11, 2021
1 parent 1198660 commit 144025a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Civi/Api4/SavedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@
*/
class SavedSearch extends Generic\DAOEntity {

public static function permissions() {
$permissions = parent::permissions();
$permissions['get'] = ['access CiviCRM'];
return $permissions;
}

}
1 change: 1 addition & 0 deletions ext/search_kit/Civi/Api4/SearchDisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static function getSearchTasks($checkPermissions = TRUE) {
public static function permissions() {
$permissions = parent::permissions();
$permissions['default'] = ['administer CiviCRM data'];
$permissions['get'] = ['access CiviCRM'];
$permissions['getSearchTasks'] = ['access CiviCRM'];
// Permission for run action is checked internally
$permissions['run'] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public function testWithACLBypass() {
}
$this->assertStringContainsString('failed', $error);

$config->userPermissionClass->permissions = ['administer CiviCRM data'];
$config->userPermissionClass->permissions = ['access CiviCRM', 'administer CiviCRM data'];

// Admins can edit the search and the display
SavedSearch::update()->addWhere('name', '=', $searchName)
Expand Down

0 comments on commit 144025a

Please sign in to comment.