Fixes #3315 by moving the manipulation of the filter widget scopes to the controller event method instead of before any part of the controller constructor method is run.
This commit is contained in:
Luke Towers 2017-12-28 13:21:00 -06:00 committed by GitHub
parent 7ffb79a5fd
commit 69e56b0b5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -49,14 +49,6 @@ class Users extends Controller
*/
public function __construct()
{
$this->user = BackendAuth::getUser();
if (!$this->user->isSuperUser()) {
// Prevent non-superusers from even seeing the is_superuser filter
$this->listConfig = $this->makeConfig($this->listConfig);
$this->listConfig->filter = $this->makeConfig($this->listConfig->filter);
unset($this->listConfig->filter->scopes['is_superuser']);
}
parent::__construct();
if ($this->action == 'myaccount') {
@ -76,6 +68,16 @@ class Users extends Controller
$query->where('is_superuser', false);
}
}
/**
* Prevents non-superusers from even seeing the is_superuser filter
*/
public function listFilterExtendScopes($filterWidget)
{
if (!$this->user->isSuperUser()) {
$filterWidget->removeScope('is_superuser');
}
}
/**
* Extends the form query to prevent non-superusers from accessing superusers at all