src/Towel/Controller/User.php
public function recoverAction($request)
    {
        $data = $request->get('data');
        $modelUser = new ModelUser;

        if ($this->isAuthenticated()) {
            $this->setMessage('error', 'Your are already authenticated.');
            return $this->redirect('/');
        }

        if (!filter_var($data['model']['email'], FILTER_VALIDATE_EMAIL)) {
            $this->setMessage('error', 'Thats is not an email');
            return $this->redirect('/user/recover');
        }

        if (!$modelUser->findByEmail($data['model']['email'])) {
            $this->setMessage('error', 'Your are not registered');
            return $this->redirect('/user/register');
        }

        //Send the email
        $password = $modelUser->regeneratePassword();
        $to = $modelUser->email;
        $subject = 'Password from Reader';
        $message = 'Your new password is ' . $password;
        $this->sendMail($to, $subject, $message);

        return $this->twig()->render('user\recoverAction.twig');
    }
public function recoverAction($request)
    {
        $data = $request->get('data');
        $modelUser = new ModelUser;

        if ($this->isAuthenticated()) {
            $this->setMessage('error', 'Your are already authenticated.');
            return $this->redirect('/');
        }

        if (!filter_var($data['model']['email'], FILTER_VALIDATE_EMAIL)) {
            $this->setMessage('error', 'Thats is not an email');
            return $this->redirect('/user/recover');
        }

        if (!$modelUser->findByEmail($data['model']['email'])) {
            $this->setMessage('error', 'Your are not registered');
            return $this->redirect('/user/register');
        }

        //Send the email
        $password = $modelUser->regeneratePassword();
        $to = $modelUser->email;
        $subject = 'Password from Reader';
        $message = 'Your new password is ' . $password;
        $this->sendMail($to, $subject, $message);

        return $this->twig()->render('user\recoverAction.twig');
    }
public function recoverAction ( $ request ) { $ data = $ request -> get ( 'data' ) ; $ modelUser = new ModelUser ; if ( $ this -> isAuthenticated ( ) ) { $ this -> setMessage ( 'error' , 'Your are already authenticated.' ) ; return $ this -> redirect ( '/' ) ; } if ( ! filter_var ( $ data [ 'model' ] [ 'email' ] , FILTER_VALIDATE_EMAIL ) ) { $ this -> setMessage ( 'error' , 'Thats is not an email' ) ; return $ this -> redirect ( '/user/recover' ) ; } if ( ! $ modelUser -> findByEmail ( $ data [ 'model' ] [ 'email' ] ) ) { $ this -> setMessage ( 'error' , 'Your are not registered' ) ; return $ this -> redirect ( '/user/register' ) ; } //Send the email $ password = $ modelUser -> regeneratePassword ( ) ; $ to = $ modelUser -> email ; $ subject = 'Password from Reader' ; $ message = 'Your new password is ' . $ password ; $ this -> sendMail ( $ to , $ subject , $ message ) ; return $ this -> twig ( ) -> render ( 'user\recoverAction.twig' ) ; }
Handles the recover action.

@param $request

@return string|\Symfony\Component\HttpFoundation\RedirectResponse
Handles the recover action .