Laděnka vypisuje Nette\Security\IAuthenticator not found
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.

- Taps
 - Člen | 169
 
Zdravím, začínám v nette a chci udělat přihlašování uživatelů.
Laděnka mi však vypisuje Service of type Nette\Security\IAuthenticator not
found. níže uvádím nastavení souborů
config.neon
common:
    dibi:
        host: localhost
        username: root
        password:
        database: ukoly
        lazy: TRUE
services:
connection:
            class: DibiConnection(%dibi%)
authenticator: Authenticator( @user )
production < common:
development < common:
profiler:
                        run: true
SignPresenter
<?php
use Nette\Application\UI,
    Nette\Security as NS;
use Nette\Application\UI\Form;
/**
 * Presenter, který se stará o přihlašování uživatelů.
 */
class SignPresenter extends BasePresenter
{
	/**
	 * Vytvoří přihlašovací formulář.
	 * @return Form
	 */
	protected function createComponentSignInForm()
	{
		$form = new Form();
		$form->addText('username', 'Uživatelské jméno:', 30, 20);
		$form->addPassword('password', 'Heslo:', 30);
		$form->addCheckbox('persistent', 'Pamatovat si mě na tomto počítači');
		$form->addSubmit('login', 'Přihlásit se');
		$form->onSuccess[] = callback($this, 'signInFormSubmitted');
		return $form;
	}
	/**
	 * Zpracuje přihlašovací formulář a přihlásí uživatele.
	 * @param Form $form
	 */
	public function signInFormSubmitted(Form $form)
	{
		try {
			$user = $this->getUser();
			$values = $form->getValues();
			if ($values->persistent) {
				$user->setExpiration('+30 days', FALSE);
			}
			$user->login($values->username, $values->password);
			$this->flashMessage('Přihlášení bylo úspěšné.', 'success');
			$this->redirect('Homepage:');
		} catch (NS\AuthenticationException $e) {
			$form->addError('Neplatné uživatelské jméno nebo heslo.');
		}
	}
	public function actionOut()
	{
		$this->getUser()->logout();
		$this->flashMessage('You have been signed out.');
		$this->redirect('in');
	}
}
Mohl by mi prosím někdo poradit jak problém odstranit. Děkuji
Editoval Taps (20. 3. 2012 19:27)

- Taps
 - Člen | 169
 
v složce models již mám soubor Authenticator.php, viz níže
class Authenticator extends Nette\Object implements NS\IAuthenticator
{
	/** @var Nette\Database\Table\Selection */
	private $users;
public function __construct(DibiConnection $connection){
        $this->db = $connection;
}
	/**
	 * Performs an authentication
	 * @param  array
	 * @return Nette\Security\Identity
	 * @throws Nette\Security\AuthenticationException
	 */
	public function authenticate(array $credentials)
	{
		list($username, $password) = $credentials;
		$row = $this->db->fetch("SELECT * FROM user WHERE login='$username'");
		if (!$row) {
			throw new NS\AuthenticationException("Uživatel '$username' nebyl nalezen.", self::IDENTITY_NOT_FOUND);
		}
		if ($row->password !== $this->calculateHash($password)) {
			throw new NS\AuthenticationException("Chybné heslo.", self::INVALID_CREDENTIAL);
		}
		unset($row->password);
		return new NS\Identity($row->id, $row->role, $row->toArray());
	}
	/**
	 * Computes salted password hash.
	 * @param  string
	 * @return string
	 */
	public function calculateHash($password)
	{
		return sha1($password);
	}
}
				
- Vojtěch Dobeš
 - Gold Partner | 1316
 
common:
	parameters:
		dibi:
			host: localhost
			username: root
			password:
			database: ukoly
			lazy: TRUE
	services:
		connection:
			factory: DibiConnection(%dibi%)
		authenticator:
			factory: Authenticator( @connection )
production < common:
Tu část pod development < common: úplně nechápu.
Editoval vojtech.dobes (20. 3. 2012 22:36)