Sets authentication handler.
public setAuthenticator ( Nette\Security\IAuthenticator $handler ) : self | ||
$handler | Nette\Security\IAuthenticator | |
return | self |
/** * 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; }
/** * @param \Nette\Security\User $user */ public function setup(User $user) { $user->getStorage()->setNamespace($this->namespace); $user->setAuthenticator($this->authenticator); $user->setAuthorizator($this->authorizator); }