diff --git a/core/src/Controllers/Password.php b/core/src/Controllers/Password.php index d363a35e92..8c48929294 100644 --- a/core/src/Controllers/Password.php +++ b/core/src/Controllers/Password.php @@ -1,6 +1,5 @@ first(); - if ($out !== null) { - return sprintf($this->managerTheme->getLexicon('error_no_privileges'), $out->username); - } - - return $out; + return null; } /** diff --git a/core/src/Controllers/Users/ChangePassword.php b/core/src/Controllers/Users/ChangePassword.php index eebc1d6803..ee6355f190 100644 --- a/core/src/Controllers/Users/ChangePassword.php +++ b/core/src/Controllers/Users/ChangePassword.php @@ -42,7 +42,8 @@ public function process() : bool } } - header("Location: index.php?a=99"); + // not the user list (a=99): it needs edit_user, which this action does not require + header("Location: index.php?a=2"); exit(); } diff --git a/core/src/Controllers/Users/DeleteUser.php b/core/src/Controllers/Users/DeleteUser.php index ef24601f3a..5a3d0ec557 100644 --- a/core/src/Controllers/Users/DeleteUser.php +++ b/core/src/Controllers/Users/DeleteUser.php @@ -53,7 +53,9 @@ public function process() : bool } } } - header("Location: index.php?a=99"); + // the user list needs edit_user, which this action does not require + $landing = $this->managerTheme->getCore()->hasPermission('edit_user') ? 99 : 2; + header("Location: index.php?a={$landing}"); exit(); } diff --git a/core/tests/Unit/Controllers/ChangePasswordRedirectTest.php b/core/tests/Unit/Controllers/ChangePasswordRedirectTest.php new file mode 100644 index 0000000000..e3558f7cb2 --- /dev/null +++ b/core/tests/Unit/Controllers/ChangePasswordRedirectTest.php @@ -0,0 +1,21 @@ +toContain('header("Location: index.php?a=2");') + ->not->toContain('Location: index.php?a=99') + ->and($theme)->toMatch('/^\s*2 => null,/m') + ->and($dashboard)->not->toContain('error_no_privileges'); +}); + +test('the user list stays closed to roles without edit_user', function () { + $list = (string) file_get_contents(dirname(__DIR__, 4) . '/manager/actions/web_user_management.static.php'); + + expect($list)->toContain("hasPermission('edit_user')"); +}); diff --git a/core/tests/Unit/Controllers/DeleteUserRedirectTest.php b/core/tests/Unit/Controllers/DeleteUserRedirectTest.php new file mode 100644 index 0000000000..9629acf56b --- /dev/null +++ b/core/tests/Unit/Controllers/DeleteUserRedirectTest.php @@ -0,0 +1,11 @@ +toContain("\$landing = \$this->managerTheme->getCore()->hasPermission('edit_user') ? 99 : 2;") + ->toContain('header("Location: index.php?a={$landing}");') + ->not->toContain('header("Location: index.php?a=99");'); +}); diff --git a/core/tests/Unit/Controllers/PasswordPageLockTest.php b/core/tests/Unit/Controllers/PasswordPageLockTest.php new file mode 100644 index 0000000000..f0282f11a0 --- /dev/null +++ b/core/tests/Unit/Controllers/PasswordPageLockTest.php @@ -0,0 +1,10 @@ +newInstanceWithoutConstructor(); + + expect($controller->checkLocked())->toBeNull(); +});