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

@@ -81,7 +81,7 @@ class App
public function __construct(array $props = [])
{
// the kirby folder directory
static::$root = dirname(dirname(__DIR__));
static::$root = dirname(__DIR__, 2);
// register all roots to be able to load stuff afterwards
$this->bakeRoots($props['roots'] ?? []);

View File

@@ -873,7 +873,7 @@ class User extends ModelWithContent
}
if (password_verify($password, $this->password()) !== true) {
throw new InvalidArgumentException(['key' => 'user.password.invalid']);
throw new InvalidArgumentException(['key' => 'user.password.notSame']);
}
return true;

View File

@@ -25,6 +25,11 @@ class UserPermissions extends ModelPermissions
protected function canChangeRole(): bool
{
// users who are not admins cannot change their own role
if ($this->user->is($this->model) === true && $this->user->isAdmin() === false) {
return false;
}
return $this->model->isLastAdmin() !== true;
}

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']);
}

View File

@@ -662,10 +662,10 @@ class Query
if ($this->debug) {
return [
'query' => $sql['query'],
'bindings' => $this->bindings(),
'options' => $params
];
'query' => $sql['query'],
'bindings' => $this->bindings(),
'options' => $params
];
}
if ($this->fail) {
@@ -697,10 +697,10 @@ class Query
if ($this->debug === true) {
return [
'query' => $sql['query'],
'bindings' => $sql['bindings'],
'options' => $params
];
'query' => $sql['query'],
'bindings' => $sql['bindings'],
'options' => $params
];
}
if ($this->fail) {

View File

@@ -110,7 +110,7 @@ class Html
}
if (is_array($value) === true) {
if (isset($value['value']) && isset($value['escape'])) {
if (isset($value['value'], $value['escape'])) {
$value = $value['escape'] === true ? htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8') : $value['value'];
} else {
$value = implode(' ', array_filter($value, function ($value) {