Skip to content

Commit

Permalink
Remove roles count check from UserPermissions
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Sep 22, 2024
1 parent c96d47f commit 3e86173
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Cms/UserPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function canChangeRole(): bool
return false;
}

return $this->model->roles()->count() > 1;
return true;
}

protected function canCreate(): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Panel/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down
2 changes: 1 addition & 1 deletion tests/Cms/Roles/RolesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function testCanBeChanged()

$app->impersonate('[email protected]');
$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('[email protected]');
$canBeChanged = $roles->canBeChanged();
Expand Down
2 changes: 1 addition & 1 deletion tests/Panel/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public function testOptions()
'changeLanguage' => true,
'changeName' => true,
'changePassword' => true,
'changeRole' => false, // just one role
'changeRole' => true,
'delete' => true,
'update' => true,
];
Expand Down

0 comments on commit 3e86173

Please sign in to comment.