diff --git a/src/Cms/UserPermissions.php b/src/Cms/UserPermissions.php index 0b6a2e2d8b..cab3776551 100644 --- a/src/Cms/UserPermissions.php +++ b/src/Cms/UserPermissions.php @@ -39,7 +39,7 @@ protected function canChangeRole(): bool return false; } - return $this->model->roles()->count() > 1; + return true; } protected function canCreate(): bool diff --git a/src/Panel/User.php b/src/Panel/User.php index 252dbabc25..75124944b0 100644 --- a/src/Panel/User.php +++ b/src/Panel/User.php @@ -70,7 +70,7 @@ public function dropdown(array $options = []): array 'dialog' => $url . '/changeRole', 'icon' => 'bolt', 'text' => I18n::translate('user.changeRole'), - 'disabled' => $this->isDisabledDropdownOption('changeRole', $options, $permissions) + 'disabled' => $this->isDisabledDropdownOption('changeRole', $options, $permissions) || $this->model->roles('change')->count() < 2 ]; $result[] = [ diff --git a/tests/Cms/Roles/RolesTest.php b/tests/Cms/Roles/RolesTest.php index 908027ee2e..ef619cb37c 100644 --- a/tests/Cms/Roles/RolesTest.php +++ b/tests/Cms/Roles/RolesTest.php @@ -151,7 +151,7 @@ public function testCanBeChanged() $app->impersonate('editor@getkirby.com'); $canBeChanged = $roles->canBeChanged(); - $this->assertCount(0, $canBeChanged); // TODO: change once `User::roles()` and `UserPermissions::canChangeRole()` have been improved/fixed + $this->assertCount(1, $canBeChanged); $app->impersonate('admin@getkirby.com'); $canBeChanged = $roles->canBeChanged(); diff --git a/tests/Panel/UserTest.php b/tests/Panel/UserTest.php index 1bb1fc9a89..a52e80d89c 100644 --- a/tests/Panel/UserTest.php +++ b/tests/Panel/UserTest.php @@ -275,7 +275,7 @@ public function testOptions() 'changeLanguage' => true, 'changeName' => true, 'changePassword' => true, - 'changeRole' => false, // just one role + 'changeRole' => true, 'delete' => true, 'update' => true, ];