src/Service/UserService.php
public function resetPassword($identity)
    {
        $user = $this->getMapper()->findByIdentity($identity);
        if (!$user instanceof UserInterface) {
            return;
        }

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

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

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

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

        $subject = 'Please, confirm your request to change password!';
        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;
    }
public function resetPassword($identity)
    {
        $user = $this->getMapper()->findByIdentity($identity);
        if (!$user instanceof UserInterface) {
            return;
        }

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

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

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

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

        $subject = 'Please, confirm your request to change password!';
        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;
    }
Reset user password

@param mixed $identity
@return UserInterface|void