Upgrade to rc5

This commit is contained in:
Bastian Allgeier
2020-12-10 11:24:42 +01:00
parent 3fec0d7c93
commit c378376bc9
257 changed files with 13009 additions and 1846 deletions

View File

@@ -368,7 +368,8 @@ class User extends ModelWithContent
*/
public function isLastAdmin(): bool
{
return $this->role()->isAdmin() === true && $this->kirby()->users()->filterBy('role', 'admin')->count() <= 1;
return $this->role()->isAdmin() === true &&
$this->kirby()->users()->filter('role', 'admin')->count() <= 1;
}
/**
@@ -381,6 +382,17 @@ class User extends ModelWithContent
return $this->kirby()->users()->count() === 1;
}
/**
* Checks if the current user is the virtual
* Nobody user
*
* @return bool
*/
public function isNobody(): bool
{
return $this->email() === 'nobody@getkirby.com';
}
/**
* Returns the user language
*
@@ -421,7 +433,7 @@ class User extends ModelWithContent
$kirby->trigger('user.login:before', ['user' => $this, 'session' => $session]);
$session->regenerateToken(); // privilege change
$session->data()->set('user.id', $this->id());
$session->data()->set('kirby.userId', $this->id());
$this->kirby()->auth()->setUser($this);
$kirby->trigger('user.login:after', ['user' => $this, 'session' => $session]);
@@ -441,7 +453,7 @@ class User extends ModelWithContent
$kirby->trigger('user.logout:before', ['user' => $this, 'session' => $session]);
// remove the user from the session for future requests
$session->data()->remove('user.id');
$session->data()->remove('kirby.userId');
// clear the cached user object from the app state of the current request
$this->kirby()->auth()->flush();
@@ -538,6 +550,18 @@ class User extends ModelWithContent
return $this->name = new Field($this, 'name', $this->credentials()['name'] ?? null);
}
/**
* Returns the user's name or,
* if empty, the email address
*
* @return \Kirby\Cms\Field
*/
public function nameOrEmail()
{
$name = $this->name();
return $name->isNotEmpty() ? $name : new Field($this, 'email', $this->email());
}
/**
* Create a dummy nobody
*
@@ -688,7 +712,7 @@ class User extends ModelWithContent
$roles = $kirby->roles();
// a collection with just the one role of the user
$myRole = $roles->filterBy('id', $this->role()->id());
$myRole = $roles->filter('id', $this->role()->id());
// if there's an authenticated user …
if ($user = $kirby->user()) {