Nette\Security\User::setAuthenticator PHP Method

setAuthenticator() public method

Sets authentication handler.
public setAuthenticator ( Nette\Security\IAuthenticator $handler ) : self
$handler Nette\Security\IAuthenticator
return self
    public function setAuthenticator(IAuthenticator $handler)
    {
        $this->authenticator = $handler;
        return $this;
    }

Usage Example

コード例 #1
0
 /**
  * main action
  * @return void
  */
 public function actionDefault()
 {
     if ($this->user->isLoggedIn()) {
         $this->flashMessage(_("You are still logged in..."), "info");
         $this->restoreRequest($this->backlink);
         $this->redirect(":Data:Browser:");
     }
     // test of use valid SSL client certificate
     if ($this->ssl->verifyClient() == true) {
         $username = $this->ssl->getUsername();
         $serial = $this->ssl->getSerial();
         $this->user->setAuthenticator(new \UserModule\SSLAuthenticator($this->db));
         try {
             // pokud to vyjde je vse OK
             $this->user->login($username, $serial);
             $this->user->getIdentity()->isSSLlogin = true;
             $this->flashMessage(_("You are logged in by SSL Certificate", "success"));
             $this->restoreRequest($this->backlink);
             $this->redirect(":Data:Browser:");
         } catch (\Nette\Security\AuthenticationException $e) {
             // pokud to nevyjde dojdte k prihlaseni jmenem a heslem
             $this->flashMessage(_("You are not logged in by SSL Certificate because of: \n" . $e->getMessage(), "warning"));
             $this->redirect("login");
         }
     } else {
         $this->flashMessage(_("You have not valid SSL certificate, please fill username and password"), "info");
         $this->redirect("login");
     }
     return;
 }
All Usage Examples Of Nette\Security\User::setAuthenticator