Exemple #1
0
 /** @noinspection PhpMissingParentCallCommonInspection */
 public function actionDefault()
 {
     // create pass recovery form
     $oForm = Form::factory('password_recovery');
     $emailField = Form\Field\Text::factory('email', $oForm)->setRequired()->setLabel('E-mail');
     $oForm->addField($emailField);
     $oForm->addField(Form\Field\Captcha::factory('captcha', $oForm));
     // if form is valid
     if ($oForm->isSubmittedAndValid()) {
         $sEmail = $oForm->getField('email')->getValueFirst();
         // find user with particular e-mail
         $query = DB::query('SELECT u FROM \\Model\\User u WHERE u.email = :email');
         $query->param('email', $sEmail);
         $oResult = $query->single();
         /* @var $oResult User */
         if ($oResult instanceof User) {
             $this->sendRecoveryCode($oResult);
             $sMessage = __("Message has been sent on your e-mail address. Click on the link from it's content to recover password to your account.");
             Session::flash(Router::getCurrentUrl(), $sMessage);
         }
     }
     // return view
     return View::factory('user/frontend/recovery/default')->bind('oForm', $oForm);
 }