Controller/Frontend/ResettingController.php
public function sendEmailAction()
    {
        $username = $this->get('request')->request->get('username');

        /** @var $user CustomerInterface */
        $user = $this->get('miky_customer_manager')->findUserByUsernameOrEmail($username);

        if (null === $user) {
            return $this->render('@MikyUser/Frontend/Resetting/request.html.twig', array('invalid_username' => $username));
        }

        if ($user->isPasswordRequestNonExpired($this->getParameter('fos_user.resetting.token_ttl'))) {
            return $this->render('@MikyUser/Frontend/Resetting/passwordAlreadyRequested.html.twig');
        }

        if (null === $user->getConfirmationToken()) {
            /** @var $tokenGenerator \FOS\UserBundle\Util\TokenGeneratorInterface */
            $tokenGenerator = $this->get('fos_user.util.token_generator');
            $user->setConfirmationToken($tokenGenerator->generateToken());
        }

        $this->get('session')->set(static::SESSION_EMAIL, $this->getObfuscatedEmail($user));
        $this->get('miky_bundle_user.mailer.mailer')->sendResettingEmailMessage($user);
        $user->setPasswordRequestedAt(new \DateTime());
        $this->get('fos_user.user_manager')->updateUser($user);

        return new RedirectResponse($this->get('router')->generate('miky_app_customer_resetting_check_email'));
    }
public function sendEmailAction()
    {
        $username = $this->get('request')->request->get('username');

        /** @var $user CustomerInterface */
        $user = $this->get('miky_customer_manager')->findUserByUsernameOrEmail($username);

        if (null === $user) {
            return $this->render('@MikyUser/Frontend/Resetting/request.html.twig', array('invalid_username' => $username));
        }

        if ($user->isPasswordRequestNonExpired($this->getParameter('fos_user.resetting.token_ttl'))) {
            return $this->render('@MikyUser/Frontend/Resetting/passwordAlreadyRequested.html.twig');
        }

        if (null === $user->getConfirmationToken()) {
            /** @var $tokenGenerator \FOS\UserBundle\Util\TokenGeneratorInterface */
            $tokenGenerator = $this->get('fos_user.util.token_generator');
            $user->setConfirmationToken($tokenGenerator->generateToken());
        }

        $this->get('session')->set(static::SESSION_EMAIL, $this->getObfuscatedEmail($user));
        $this->get('miky_bundle_user.mailer.mailer')->sendResettingEmailMessage($user);
        $user->setPasswordRequestedAt(new \DateTime());
        $this->get('fos_user.user_manager')->updateUser($user);

        return new RedirectResponse($this->get('router')->generate('miky_app_customer_resetting_check_email'));
    }
public function sendEmailAction ( ) { $ username = $ this -> get ( 'request' ) -> request -> get ( 'username' ) ; /** @var $user CustomerInterface */ $ user = $ this -> get ( 'miky_customer_manager' ) -> findUserByUsernameOrEmail ( $ username ) ; if ( null === $ user ) { return $ this -> render ( '@MikyUser/Frontend/Resetting/request.html.twig' , array ( 'invalid_username' => $ username ) ) ; } if ( $ user -> isPasswordRequestNonExpired ( $ this -> getParameter ( 'fos_user.resetting.token_ttl' ) ) ) { return $ this -> render ( '@MikyUser/Frontend/Resetting/passwordAlreadyRequested.html.twig' ) ; } if ( null === $ user -> getConfirmationToken ( ) ) { /** @var $tokenGenerator \FOS\UserBundle\Util\TokenGeneratorInterface */ $ tokenGenerator = $ this -> get ( 'fos_user.util.token_generator' ) ; $ user -> setConfirmationToken ( $ tokenGenerator -> generateToken ( ) ) ; } $ this -> get ( 'session' ) -> set ( static :: SESSION_EMAIL , $ this -> getObfuscatedEmail ( $ user ) ) ; $ this -> get ( 'miky_bundle_user.mailer.mailer' ) -> sendResettingEmailMessage ( $ user ) ; $ user -> setPasswordRequestedAt ( new \ DateTime ( ) ) ; $ this -> get ( 'fos_user.user_manager' ) -> updateUser ( $ user ) ; return new RedirectResponse ( $ this -> get ( 'router' ) -> generate ( 'miky_app_customer_resetting_check_email' ) ) ; }
Request reset user password: submit form and send email
Request reset user password : submit form and send email