Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .semver
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
:major: 14
:minor: 3
:patch: 3
:patch: 4
:special: ''
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Changelog
=========
Releases for CakePHP 5
-------------
* 14.3.4
* Replace usage of 'admin' by UsersTable::ROLE_ADMIN constant across the plugin.
* Fix role in UsersAddSuperuserCommand to be 'admin' instead of 'superadmin'.
* 14.3.3
* Add compatibility with CakePHP 5.1
* 14.3.2
Expand Down
2 changes: 1 addition & 1 deletion config/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
],
//admin role allowed to all the things
[
'role' => 'admin',
'role' => \CakeDC\Users\Model\Table\UsersTable::ROLE_ADMIN,
'prefix' => '*',
'extension' => '*',
'plugin' => '*',
Expand Down
3 changes: 2 additions & 1 deletion src/Command/UsersAddSuperuserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use CakeDC\Users\Command\Logic\CreateUserTrait;
use CakeDC\Users\Model\Table\UsersTable;

/**
* UsersAddSuperuser command.
Expand All @@ -26,7 +27,7 @@ public function execute(Arguments $args, ConsoleIo $io)
{
$this->_createUser($args, $io, [
'username' => 'superadmin',
'role' => 'superuser',
'role' => UsersTable::ROLE_ADMIN,
'is_superuser' => true,
]);
}
Expand Down
11 changes: 6 additions & 5 deletions tests/Fixture/UsersFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace CakeDC\Users\Test\Fixture;

use Cake\TestSuite\Fixture\TestFixture;
use CakeDC\Users\Model\Table\UsersTable;
use CakeDC\Users\Webauthn\Base64Utility;

/**
Expand Down Expand Up @@ -44,7 +45,7 @@ public function init(): void
'tos_date' => '2015-06-24 17:33:54',
'active' => false,
'is_superuser' => true,
'role' => 'admin',
'role' => UsersTable::ROLE_ADMIN,
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54',
'additional_data' => [
Expand Down Expand Up @@ -85,7 +86,7 @@ public function init(): void
'tos_date' => '2015-06-24 17:33:54',
'active' => true,
'is_superuser' => true,
'role' => 'admin',
'role' => UsersTable::ROLE_ADMIN,
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54',
'last_login' => '2015-06-24 17:33:54',
Expand All @@ -106,7 +107,7 @@ public function init(): void
'is_superuser' => true,
'tos_date' => '2015-06-24 17:33:54',
'active' => false,
'role' => 'admin',
'role' => UsersTable::ROLE_ADMIN,
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54',
],
Expand Down Expand Up @@ -146,7 +147,7 @@ public function init(): void
'tos_date' => '2015-06-24 17:33:54',
'active' => true,
'is_superuser' => false,
'role' => 'user',
'role' => UsersTable::ROLE_USER,
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54',
],
Expand All @@ -166,7 +167,7 @@ public function init(): void
'tos_date' => '2015-06-24 17:33:54',
'active' => true,
'is_superuser' => false,
'role' => 'user',
'role' => UsersTable::ROLE_USER,
'created' => '2015-06-24 17:33:54',
'modified' => '2015-06-24 17:33:54',
],
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Command/UsersAddSuperuserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use CakeDC\Users\Model\Table\UsersTable;

/**
* CakeDC\Users\Command\UsersAddSuperuserCommand Test Case
Expand Down Expand Up @@ -66,7 +67,7 @@ public function testExecuteWithNoParams(): void
$this->assertOutputRegExp('/^Superuser added:/');
$this->assertOutputRegExp('/Username: superadmin/');
$this->assertOutputRegExp('/Email: superadmin@example.com/');
$this->assertOutputRegExp('/Role: superuser/');
$this->assertOutputRegExp('/Role: ' . UsersTable::ROLE_ADMIN . '/');
$this->assertOutputRegExp('/Password: [a-z0-9]{32}$/');
}
}
9 changes: 5 additions & 4 deletions tests/TestCase/Command/UsersChangeRoleCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use CakeDC\Users\Model\Table\UsersTable;

/**
* CakeDC\Users\Command\UsersChangeRoleCommand Test Case
Expand Down Expand Up @@ -37,8 +38,8 @@ public function testExecute(): void
$userId006 = '00000000-0000-0000-0000-000000000006';
$roleBefore = 'Lorem ipsum dolor sit amet';
$userId001 = '00000000-0000-0000-0000-000000000001';
$role001 = 'admin';
$role006 = 'user';
$role001 = UsersTable::ROLE_ADMIN;
$role006 = UsersTable::ROLE_USER;
$this->assertTrue($UsersTable->exists(['id' => $userIdTarget, 'role' => $roleBefore]));
$this->assertTrue($UsersTable->exists(['id' => $userId001, 'role' => $role001]));
$this->assertTrue($UsersTable->exists(['id' => $userId006, 'role' => $role006]));
Expand Down Expand Up @@ -71,8 +72,8 @@ public function testExecuteMissingInfo(string $command, $expectedMessage): void
$userId006 = '00000000-0000-0000-0000-000000000006';
$roleBefore = 'Lorem ipsum dolor sit amet';
$userId001 = '00000000-0000-0000-0000-000000000001';
$role001 = 'admin';
$role006 = 'user';
$role001 = UsersTable::ROLE_ADMIN;
$role006 = UsersTable::ROLE_USER;
$this->assertTrue($UsersTable->exists(['id' => $userIdTarget, 'role' => $roleBefore]));
$this->assertTrue($UsersTable->exists(['id' => $userId001, 'role' => $role001]));
$this->assertTrue($UsersTable->exists(['id' => $userId006, 'role' => $role006]));
Expand Down
Loading