Fix User\Save

This commit is contained in:
Visman 2021-12-04 21:27:22 +07:00
parent 28c24e1849
commit b137e6de94

View file

@ -21,21 +21,22 @@ class Save extends Action
*/
public function update(User $user): User
{
if ($user->id < 1) {
throw new RuntimeException('The model does not have ID');
if (
(! $user->isGuest && $user->id < 1)
|| ($user->isGuest && 0 !== $user->id)
) {
throw new RuntimeException('Bad ID');
}
$modified = $user->getModified();
if (empty($modified)) {
return $user;
}
$values = $user->getAttrs();
if (
$user->isGuest
&& ! $user->isUnverified
) {
if ($user->isGuest) {
$fileds = $this->c->dbMap->online;
$table = 'online';
$where = 'user_id=0 AND ident=?s';
@ -113,6 +114,8 @@ class Save extends Action
{
if (null !== $user->id) {
throw new RuntimeException('The model has ID');
} elseif ($user->isGuest) {
throw new RuntimeException('Unexpected guest');
}
// вычисление username_normal для нового пользователя