id instanceof UserEntity ? $cmd->id : $this->repo->ofUniqueKey($cmd->id); $user->resetPassword($cmd->token, $cmd->newPassword); // Dispatch the user password updated event $event = new UserPasswordUpdatedEvent($user); $this->dispatcher->dispatch($event); return $user; } }