Authenticator has not been set
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Piticu
- Člen | 93
Ahoj vsem. Nedavno jsem se zacal ucit NetteFramework a pan David Grugl ma
nejake priklady na GitHubu. (https://github.com/nette/examples).
Vzal jsem prvni priklad CD-Collection a vyzkousel jsem si vytvorit svuj projekt,
kde misto db3 pouzivam normalne MySQL. Zaseknul jsem se u jedne chybove hlasky.
Vubec nevim jak pokracovat.
Pridavam obrazek a kod:
https://s32.postimg.org/…ez_n_zvu.jpg
config.neon
parameters:
php:
date.timezone: Europe/Prague
application:
errorPresenter: Error
mapping:
*: App\*Module\Presenters\*Presenter
services:
- App\Model\Authenticator
- App\Model\AlbumRepository
SignPresenter
<?php
namespace App\Presenters;
use Nette;
use Nette\Application\UI;
class SignPresenter extends Nette\Application\UI\Presenter
{
/** @persistent */
public $backlink = '';
/**
* Sign-in form factory.
* @return Nette\Application\UI\Form
*/
protected function createComponentSignInForm()
{
$form = new UI\Form;
$form->addText('username', 'Username:')
->setRequired('Please enter your username.');
$form->addPassword('password', 'Password:')
->setRequired('Please enter your password.');
$form->addSubmit('send', 'Sign in');
$form->onSuccess[] = [$this, 'signInFormSucceeded'];
return $form;
}
public function signInFormSucceeded($form, $values)
{
try {
$this->getUser()->login($values->username, $values->password);
} catch (Nette\Security\AuthenticationException $e) {
$form->addError($e->getMessage());
return;
}
$this->restoreRequest($this->backlink);
$this->redirect('Dashboard:');
}
public function actionOut()
{
$this->getUser()->logout();
$this->flashMessage('You have been signed out.');
$this->redirect('in');
}
}
Editoval Piticu (16. 6. 2016 20:59)