public function confirmPasswordReset($token)
    {
        $user = $this->getMapper()->findOneBy(['registrationToken' => $token]);
        if (!$user instanceof UserInterface) {
            return;
        }

        $eventManager = $this->getEventManager();
        $eventManager->trigger(__METHOD__, $this, $user);

        $user->setRegistrationToken($this->getRegistrationToken());
        $user->setEmailConfirmed(true);

        $password = $this->getPasswordGenerator()->generate();
        $passwordService = $this->getMapper()->getPasswordService();
        $user->setPassword($passwordService->create($password));

        $viewModel = new ViewModel(compact('user', 'password'));
        $viewModel->setTemplate('mail-message/user-change-password-success');

        $mailService = $this->getMailService();
        $message = $mailService->getMessage();
        $message->setTo($user->getEmail(), $user->getDisplayName());

        $subject = 'Your password has been changed!';
        if ($this->getTranslator() && $this->isTranslatorEnabled()) {
            $subject = $this->getTranslator()->translate(
                $subject,
                $this->getTranslatorTextDomain()
            );
        }
        $message->setSubject($subject);

        $mailService->setBody($viewModel)->sendMessage();

        $this->getMapper()->update($user)->save();

        $eventManager->trigger(__METHOD__ . '.post', $this, $user);

        return $user;
    }