Skip to content

UserModel::save() can't update User's email/password #254

Closed
@kenjis

Description

@kenjis

When updating User's email/password, parent::save($data) may returns DataException (no data to update),
in that case, email/password is not updated.

public function save($data): bool
{
try {
$result = parent::save($data);
if ($result && $data instanceof User) {
/** @var User $user */
$user = $data->id === null
? $this->find($this->db->insertID())
: $data;
if (! $user->saveEmailIdentity()) {
throw new RuntimeException('Unable to save email identity.');
}
}
return $result;
} catch (DataException $e) {
$messages = [
lang('Database.emptyDataset', ['insert']),
lang('Database.emptyDataset', ['update']),
];
if (in_array($e->getMessage(), $messages, true)) {
// @TODO Why true? Shouldn't this workaround be removed?
return true;
}
throw $e;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions