Skip to content

Commit ec78329

Browse files
committed
1108 - Fix usage of superadmin and admin across the plugin
1 parent a464935 commit ec78329

File tree

6 files changed

+21
-14
lines changed

6 files changed

+21
-14
lines changed

.semver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
:major: 14
33
:minor: 3
4-
:patch: 2
4+
:patch: 3
55
:special: ''

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ Changelog
22
=========
33
Releases for CakePHP 5
44
-------------
5+
* 14.3.3
6+
* Add compatibility with CakePHP 5.1
7+
* Replace usage of 'admin' by UsersTable::ROLE_ADMIN constant across the plugin.
8+
* Fix role in UsersAddSuperuserCommand to be 'admin' instead of 'superadmin'.
59
* 14.3.2
6-
* Fix missing spanish translations
10+
* Fix missing spanish translations
711
* 14.3.1
812
* Fix duplicated rule name in rules checker
913
* 14.3.0
@@ -13,7 +17,7 @@ Releases for CakePHP 5
1317
* #1096: fixed findExistingForSocialLogin finder by @arusinowski in #1097
1418
* 14.2.1
1519
* Improve documentation about password meter.
16-
* Fix minor bugs
20+
* Fix minor bugs
1721
* 14.2.0
1822
* Add password meter to display password quality
1923
* Add integration with google reCaptcha v3, keep default using v2

config/permissions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
],
9595
//admin role allowed to all the things
9696
[
97-
'role' => 'admin',
97+
'role' => \CakeDC\Users\Model\Table\UsersTable::ROLE_ADMIN,
9898
'prefix' => '*',
9999
'extension' => '*',
100100
'plugin' => '*',

src/Command/UsersAddSuperuserCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Cake\Console\Arguments;
88
use Cake\Console\ConsoleIo;
99
use CakeDC\Users\Command\Logic\CreateUserTrait;
10+
use CakeDC\Users\Model\Table\UsersTable;
1011

1112
/**
1213
* UsersAddSuperuser command.
@@ -26,7 +27,7 @@ public function execute(Arguments $args, ConsoleIo $io)
2627
{
2728
$this->_createUser($args, $io, [
2829
'username' => 'superadmin',
29-
'role' => 'superuser',
30+
'role' => UsersTable::ROLE_ADMIN,
3031
'is_superuser' => true,
3132
]);
3233
}

tests/Fixture/UsersFixture.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace CakeDC\Users\Test\Fixture;
1414

1515
use Cake\TestSuite\Fixture\TestFixture;
16+
use CakeDC\Users\Model\Table\UsersTable;
1617
use CakeDC\Users\Webauthn\Base64Utility;
1718

1819
/**
@@ -44,7 +45,7 @@ public function init(): void
4445
'tos_date' => '2015-06-24 17:33:54',
4546
'active' => false,
4647
'is_superuser' => true,
47-
'role' => 'admin',
48+
'role' => UsersTable::ROLE_ADMIN,
4849
'created' => '2015-06-24 17:33:54',
4950
'modified' => '2015-06-24 17:33:54',
5051
'additional_data' => [
@@ -85,7 +86,7 @@ public function init(): void
8586
'tos_date' => '2015-06-24 17:33:54',
8687
'active' => true,
8788
'is_superuser' => true,
88-
'role' => 'admin',
89+
'role' => UsersTable::ROLE_ADMIN,
8990
'created' => '2015-06-24 17:33:54',
9091
'modified' => '2015-06-24 17:33:54',
9192
'last_login' => '2015-06-24 17:33:54',
@@ -106,7 +107,7 @@ public function init(): void
106107
'is_superuser' => true,
107108
'tos_date' => '2015-06-24 17:33:54',
108109
'active' => false,
109-
'role' => 'admin',
110+
'role' => UsersTable::ROLE_ADMIN,
110111
'created' => '2015-06-24 17:33:54',
111112
'modified' => '2015-06-24 17:33:54',
112113
],
@@ -146,7 +147,7 @@ public function init(): void
146147
'tos_date' => '2015-06-24 17:33:54',
147148
'active' => true,
148149
'is_superuser' => false,
149-
'role' => 'user',
150+
'role' => UsersTable::ROLE_USER,
150151
'created' => '2015-06-24 17:33:54',
151152
'modified' => '2015-06-24 17:33:54',
152153
],
@@ -166,7 +167,7 @@ public function init(): void
166167
'tos_date' => '2015-06-24 17:33:54',
167168
'active' => true,
168169
'is_superuser' => false,
169-
'role' => 'user',
170+
'role' => UsersTable::ROLE_USER,
170171
'created' => '2015-06-24 17:33:54',
171172
'modified' => '2015-06-24 17:33:54',
172173
],

tests/TestCase/Command/UsersChangeRoleCommandTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
77
use Cake\ORM\TableRegistry;
88
use Cake\TestSuite\TestCase;
9+
use CakeDC\Users\Model\Table\UsersTable;
910

1011
/**
1112
* CakeDC\Users\Command\UsersChangeRoleCommand Test Case
@@ -37,8 +38,8 @@ public function testExecute(): void
3738
$userId006 = '00000000-0000-0000-0000-000000000006';
3839
$roleBefore = 'Lorem ipsum dolor sit amet';
3940
$userId001 = '00000000-0000-0000-0000-000000000001';
40-
$role001 = 'admin';
41-
$role006 = 'user';
41+
$role001 = UsersTable::ROLE_ADMIN;
42+
$role006 = UsersTable::ROLE_USER;
4243
$this->assertTrue($UsersTable->exists(['id' => $userIdTarget, 'role' => $roleBefore]));
4344
$this->assertTrue($UsersTable->exists(['id' => $userId001, 'role' => $role001]));
4445
$this->assertTrue($UsersTable->exists(['id' => $userId006, 'role' => $role006]));
@@ -71,8 +72,8 @@ public function testExecuteMissingInfo(string $command, $expectedMessage): void
7172
$userId006 = '00000000-0000-0000-0000-000000000006';
7273
$roleBefore = 'Lorem ipsum dolor sit amet';
7374
$userId001 = '00000000-0000-0000-0000-000000000001';
74-
$role001 = 'admin';
75-
$role006 = 'user';
75+
$role001 = UsersTable::ROLE_ADMIN;
76+
$role006 = UsersTable::ROLE_USER;
7677
$this->assertTrue($UsersTable->exists(['id' => $userIdTarget, 'role' => $roleBefore]));
7778
$this->assertTrue($UsersTable->exists(['id' => $userId001, 'role' => $role001]));
7879
$this->assertTrue($UsersTable->exists(['id' => $userId006, 'role' => $role006]));

0 commit comments

Comments
 (0)