Nette\Security\User::getAuthenticator PHP Method

getAuthenticator() public method

Returns authentication handler.
public getAuthenticator ( $need = TRUE ) : Nette\Security\IAuthenticator
return Nette\Security\IAuthenticator
    public function getAuthenticator($need = TRUE)
    {
        if ($need && !$this->authenticator) {
            throw new Nette\InvalidStateException('Authenticator has not been set.');
        }
        return $this->authenticator;
    }

Usage Example

コード例 #1
0
 /**
  * process to reset form
  * @param \Nette\Application\UI\Form $form
  * @return void
  */
 public function processResetForm(\Nette\Application\UI\Form $form)
 {
     $values = $form->getValues();
     $this->user->setAuthenticator(new \UserModule\Authenticator($this->db));
     try {
         $data = $this->user->getAuthenticator()->resetPassword($values->username, $values->email);
         $message = new \Nette\Mail\Message();
         $message->setFrom('system@occ2')->addTo($data["email"])->setSubject(_("Reset password"))->setBody(_("Hello your new reseted password is ") . $data["password"]);
         $mail = new \Nette\Mail\SendmailMailer();
         $mail->send($message);
         $this->flashMessage(_("Your new password was send to your email", "success"));
         $this->redirect("login");
     } catch (\Nette\Security\AuthenticationException $exc) {
         $this->flashMessage($exc->getMessage(), "danger");
         $this->redirect("this");
     }
 }