diff --git a/modules/backend/controllers/Users.php b/modules/backend/controllers/Users.php index 2da15ea2d..6aba91696 100644 --- a/modules/backend/controllers/Users.php +++ b/modules/backend/controllers/Users.php @@ -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