Пример #1
0
 public function lostpasswordAction()
 {
     $form = new LostPasswordForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $account = new Account();
         $form->setInputFilter($account->getLostPasswordInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $account->exchangeArray($form->getData());
             $account = $this->getAccountTable()->getAccountBy(['email' => $account->getEmail()]);
             if (!$account) {
                 return $this->redirect()->toRoute('account', ['action' => 'nouser']);
             }
             $account->setUserHash(hash('sha256', $account->getName()));
             $this->getAccountTable()->saveAccount($account);
             $this->sendLostPasswordMail($account);
             return $this->redirect()->toRoute('account', ['action' => 'lostpasswordsuccess']);
         }
         return ['form' => $form, 'errors' => 'No valid E-Mail adress'];
     }
     return ['form' => $form];
 }