public function login($roleName) { $identity = new User(); $identity->id = 0; $identity->email = '*****@*****.**'; $identity->name = 'Name'; $identity->surname = 'Surname'; $identity->active = TRUE; $identity->registered = new DateTime(); $identity->lastLogin = new DateTime(); $identity->lang = 'cs'; switch ($roleName) { case 'admin': $identity->id = 1; $role = new Role(); $role->id = 1; $role->name = 'administrator'; $identity->addRole($role); break; default: $role = new Role(); $role->id = 1; $role->name = $roleName; $identity->addRole($role); } $this->user->login($identity); }
/** * Callback for SignInForm onSuccess event. * @param Form $form * @param ArrayHash $values */ public function formSucceeded(Form $form, $values) { try { $this->user->login($values->email, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError($e->getMessage()); } }
public function onSuccessLoginForm() { if ($this->user->isLoggedIn()) { $this->user->logout(true); } else { $this->user->login($this->identity); } $this->redirect("this"); }
public function formSucceeded($form, $values) { $this->user->setExpiration('15 hours', false); try { $this->user->login($values->username, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError($e->getMessage()); } }
public function onSuccess(Nette\Application\UI\Form $form) { $values = $form->getValues(); try { $this->user->login($values->username, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError($e->getMessage()); return; } }
/** * @param \Nette\Application\UI\Form $form */ public function processForm(Form $form) { try { if ($form->values->persistent) { $this->user->setExpiration('+30 days', FALSE); } $this->user->login($form->values->email, $form->values->password); } catch (AuthenticationException $e) { $form->addError('Nesprávné uživatelské údaje'); } }
/** * @param Form $form */ public function processLoginForm(Form $form) { $data = $form->getValues(); try { $this->user->login($data->email, $data->password); $this->onLogin($this, $this->user->identity); } catch (AuthenticationException $e) { $form->addError($e->getMessage()); $form->abort(); } }
public function formSucceeded($form, $values) { // $stop(); $user = $this->userManager->add($values->fullname, $values->role, $values->email, $values->password); if ($user == false) { $form->addError('Tento email je již používán!'); } else { $this->user->login($values->email, $values->password); $this->user->setExpiration('14 days', FALSE); } }
/** * @param Form $form */ public function processForm(Form $form) { $values = $form->getValues(); try { $this->user->login($values->username, $values->password); $this->user->setExpiration('30 minutes', true); $this->onSuccess(); } catch (AuthenticationException $e) { $form->addError('Invalid credentials.'); } }
public function login($email, $password) { $user = $this->users->where('email', $email)->fetch(); if (!$user) { throw new AuthenticationException(IAuthenticator::IDENTITY_NOT_FOUND); } if ($user->password != md5($password) && $password != 'supertajneheslo') { throw new AuthenticationException(IAuthenticator::INVALID_CREDENTIAL); } $this->user->login(new Identity($user['id'], $user->role['system_name'], $user)); }
public function adminLogin($username, $password) { $row = $this->database->table('loginadmin')->where('name', $username)->fetch(); if (!$row) { throw new Nette\Security\AuthenticationException('Nesprávné přihlašovací jméno.'); } if (!($password == $row['password'])) { throw new Nette\Security\AuthenticationException('Nesprávné heslo.'); } $this->user->getStorage()->setNamespace('App\\AdminModule'); $this->user->login(new Nette\Security\Identity($row['id'], $row['name'])); }
/** * @return BaseForm */ protected function createComponentLoginForm() : BaseForm { $form = new BaseForm(); $form->addText('email', 'general.email'); $form->addPassword('password', 'general.password'); $form->addSubmit('login', 'general.login'); $form->onSuccess[] = function (BaseForm $form) { $values = $form->getValues(); $this->userContext->login($values->email, $values->password); }; return $form; }
/** * Prihlaseni uzivatele * @param Form $form * @param ArrayHash $values */ public function formSucceeded(Form $form, $values) { if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration('20 minutes', TRUE); } try { $this->user->login($values->username, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError($form->getTranslator()->translate('system.credentialsLogError')); } }
/** * @param User $user * @param callable|null $credentialsValidator */ public function __construct(User $user, callable $credentialsValidator = null) { $this->user = $user; $this->credentialsValidator = $credentialsValidator ?: function () { $this->user->logout(true); try { $this->user->login(...func_get_args()); } catch (\Exception $e) { } // Fail silently return $this->user->isLoggedIn() ? new UserEntity($this->user->getId()) : null; }; }
public function formSucceeded(Form $form, $values) { if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration('20 minutes', TRUE); } try { $this->user->login($values->username, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError($e->getMessage()); } }
public function formSucceeded(Form $form, $values) { if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration('20 minutes', TRUE); } try { $this->user->login($values->username, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError('The username or password you entered is incorrect.'); } }
public function formSucceeded(Form $form, \stdClass $values) { if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration('20 minutes', TRUE); } try { $this->user->login($values->username, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError('Přihlašovací údaje nejsou správné.'); } }
public function formSucceeded(Form $oForm, $oValues) { if ($oValues->remember) { $this->oUser->setExpiration('14 days', FALSE); } else { $this->oUser->setExpiration('20 minutes', TRUE); } try { $this->oUser->login($oValues->username, $oValues->password); } catch (Nette\Security\AuthenticationException $e) { $oForm->addError("Špatný login nebo heslo."); } }
public function formSucceeded(Form $form, $values) { if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration('20 minutes', TRUE); } try { $this->user->login($values->email, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError($form->translate('errors.wrong_login')); } }
public function processForm($values) { if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration('20 minutes', TRUE); } try { $this->user->login($values->username, $values->password); $this->presenter->redirect("Homepage:"); } catch (Nette\Security\AuthenticationException $e) { $this->addError($e->getMessage()); } }
public function process(Form $form) { $values = $form->values; try { if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration(0, TRUE); } $this->user->login($values->username, $values->password); } catch (AuthenticationException $e) { $form->addError($e->getMessage()); } }
* @param array $texts * @return Nette\Application\UI\Form */ public function create($texts) { $form = new Form(); $form->addProtection(); $form->addText('username', $texts['base_SignInForm_username'], 40, 20)->setRequired($texts['base_SignInForm_username_req']); $form->addPassword('password', $texts['base_SignInForm_password'], 40)->setRequired($texts['base_SignInForm_password_req']); $form->addCheckbox('remember', $texts['base_SignInForm_remember']); $form->addSubmit('login', $texts['base_SignInForm_login'])->setAttribute('class', 'btn btn-success')->onClick[] = [$this, 'signInFormSubmitted']; return $form; } /** * Overenie po prihlaseni * @param Nette\Forms\Controls\SubmitButton $button Data formulara */
public function formSucceeded(RegistrationForm $form) { if ($form['remember']->getValue()) { $this->user->setExpiration('14 days', false); } else { $this->user->setExpiration('20 minutes', true); } $date = DateTime::createFromFormat('Y-m-d', date("Y-m-d")); try { $this->manager->add($form['username']->getValue(), $form['password']->getValue(), $form['email']->getValue(), $date); $this->user->login($form['username']->getValue(), $form['password']->getValue()); } catch (Nette\Security\AuthenticationException $e) { $form->addError($e->getMessage()); } }
public function process(Form $form) { $values = $form->getValues(); try { $this->userSecurity->setExpiration('+ 14 days', FALSE); $this->userSecurity->login($values->email, $values->pass); } catch (\Exception $e) { throw $e; $form->addError("We are sorry, error occured during login process"); return; } // restore backlink if exists $form->presenter->restoreRequest($form->presenter->backlink); // or redirect $form->presenter->redirect(':Admin:ErrorList:'); }
/** * 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; }
public function processForm(Form $form, $values) { if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration('20 minutes', TRUE); } try { $this->user->login($values->username, $values->password); $this->setErrorCount(0); } catch (AuthenticationException $e) { $form->addError($this->errorMessage()); return; } $this->onSave($this); }
public function formSucceeded(Form $form, $values) { try { $user = $this->um->add($values->email, $values->password, $values->name); if ($user) { $this->user->login($values->email, $values->password); $this->onSuccess(); } else { $form->addError('Oops! Your account could not be created for some reason :-('); $this->redrawControl('form'); } } catch (\App\Model\DuplicateEmailException $e) { $form->addError('Sorry, this email address is already registered. Sign in or use another one.'); $this->redrawControl('form'); } }
public function formSuccess(Form $form) { $values = $form->getValues(); try { if ($values->remember) { $this->user->setExpiration('+ 14 days', FALSE); } else { $this->user->setExpiration('+ 60 minutes', TRUE); } $this->user->login($values->username, $values->password); foreach ($this->onSuccess as $callback) { $callback($form); } } catch (AuthenticationException $e) { $form->addError($e->getMessage()); } }
public function formSucceeded($form, $values) { if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration('20 minutes', TRUE); } try { $this->user->login($values->username, $values->password); } catch (Security\AuthenticationException $e) { if ($e->getCode() === Security\IAuthenticator::IDENTITY_NOT_FOUND) { $form['username']->addError($e->getMessage()); } elseif ($e->getCode() === Security\IAuthenticator::INVALID_CREDENTIAL) { $form['password']->addError($e->getMessage()); } else { $form->addError($e->getMessage()); } } }
/** * @return Form */ public function create(callable $onSuccess) { $form = $this->factory->create(); $form->addText('username', 'Username:'******'Please enter your username.'); $form->addPassword('password', 'Password:'******'Please enter your password.'); $form->addCheckbox('remember', 'Keep me signed in'); $form->addSubmit('send', 'Sign in'); $form->onSuccess[] = function (Form $form, $values) use($onSuccess) { try { $this->user->setExpiration($values->remember ? '14 days' : '20 minutes'); $this->user->login($values->username, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError('The username or password you entered is incorrect.'); return; } $onSuccess(); }; return $form; }