Upgrade to 3.9.0

This commit is contained in:
Bastian Allgeier
2023-01-17 14:50:16 +01:00
parent 0ebe0c7b16
commit 6e5c9d1f48
132 changed files with 1664 additions and 1254 deletions

View File

@@ -8,6 +8,7 @@ use Kirby\Exception\LogicException;
use Kirby\Exception\PermissionException;
use Kirby\Toolkit\Str;
use Kirby\Toolkit\V;
use SensitiveParameter;
/**
* Validators for all user actions
@@ -83,13 +84,13 @@ class UserRules
/**
* Validates if the password can be changed
*
* @param \Kirby\Cms\User $user
* @param string $password
* @return bool
* @throws \Kirby\Exception\PermissionException If the user is not allowed to change the password
*/
public static function changePassword(User $user, string $password): bool
{
public static function changePassword(
User $user,
#[SensitiveParameter]
string $password
): bool {
if ($user->permissions()->changePassword() !== true) {
throw new PermissionException([
'key' => 'user.changePassword.permission',
@@ -193,12 +194,13 @@ class UserRules
}
// check user permissions (if not on install)
if ($user->kirby()->users()->count() > 0) {
if ($user->permissions()->create() !== true) {
throw new PermissionException([
'key' => 'user.create.permission'
]);
}
if (
$user->kirby()->users()->count() > 0 &&
$user->permissions()->create() !== true
) {
throw new PermissionException([
'key' => 'user.create.permission'
]);
}
return true;
@@ -332,13 +334,13 @@ class UserRules
/**
* Validates a password
*
* @param \Kirby\Cms\User $user
* @param string $password
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException If the password is too short
*/
public static function validPassword(User $user, string $password): bool
{
public static function validPassword(
User $user,
#[SensitiveParameter]
string $password
): bool {
if (Str::length($password ?? null) < 8) {
throw new InvalidArgumentException([
'key' => 'user.password.invalid',