Upgrade to 3.2.1

This commit is contained in:
Bastian Allgeier
2019-07-09 16:45:40 +02:00
parent 7b4170f17e
commit 2694b3d76f
38 changed files with 282 additions and 150 deletions

View File

@@ -70,6 +70,13 @@ class UserRules
public static function changeRole(User $user, string $role): bool
{
if ($user->kirby()->user()->isAdmin() === false) {
throw new PermissionException([
'key' => 'user.changeRole.permission',
'data' => ['name' => $user->username()]
]);
}
static::validRole($user, $role);
if ($role !== 'admin' && $user->isLastAdmin() === true) {
@@ -95,6 +102,15 @@ class UserRules
static::validEmail($user, $user->email(), true);
static::validLanguage($user, $user->language());
// only admins are allowed to add admins
$role = $props['role'] ?? null;
if ($role === 'admin' && $user->kirby()->user()->isAdmin() === false) {
throw new PermissionException([
'key' => 'user.create.permission'
]);
}
if (empty($props['password']) === false) {
static::validPassword($user, $props['password']);
}