Exemplo n.º 1
0
 function postContent()
 {
     $this->reverseGatekeeper();
     $email_address = $this->getInput('email');
     if ($user = User::getByEmail($email_address)) {
         if ($auth_code = $user->addPasswordRecoveryCode()) {
             $user->save();
             // Save the recovery code to the user
             $t = clone \Idno\Core\site()->template();
             $t->setTemplateType('email');
             $email = new Email();
             $email->setSubject("Password reset");
             $email->addTo($user->email);
             $email->setHTMLBody($t->__(array('email' => $email_address, 'code' => $auth_code))->draw('account/password'));
             $email->send();
             $this->forward(\Idno\Core\site()->config()->getURL() . 'account/password/?sent=true');
         }
     }
     \Idno\Core\site()->session()->addErrorMessage("Oh no! We couldn't find an account associated with that email address.");
     $this->forward(\Idno\Core\site()->config()->getURL() . 'account/password');
 }