Update Post\Model

There is a need to think about how to unbind id =1 from the guest :(
This commit is contained in:
Visman 2021-03-20 22:12:01 +07:00
parent d41f4d1501
commit 2af02b0286

View file

@ -60,9 +60,16 @@ class Model extends DataModel
{
$user = $this->c->users->load($this->poster_id);
if (
! $user instanceof User
&& 1 !== $this->poster_id // ???? может сменить id гостя?
) {
$user = $this->c->users->load(1);
}
if (! $user instanceof User) {
throw new RuntimeException('No user data in post number ' . $this->id);
} elseif (1 === $this->poster_id) {
throw new RuntimeException("No user data in post number {$this->id}");
} elseif ($user->isGuest) {
$user = clone $user;
$user->__email = $this->poster_email;