/** * Performs an authentication. * @return Nette\Security\Identity * @throws Nette\Security\AuthenticationException */ public function authenticate(array $credentials) { list($username, $password) = $credentials; $row = $this->database->table('users')->where('username', $username)->fetch(); if (!$row) { throw new Security\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND); } if ($row->password !== $this->calculateHash($password, $row->password)) { throw new Security\AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL); } unset($row->password); return new Security\Identity($row->id, $row->role, $row->toArray()); }
/** * Performs an authentication. * @return Nette\Security\Identity * @throws Nette\Security\AuthenticationException */ public function authenticate(array $credentials) { list($username, $password) = $credentials; $row = $this->database->table(self::TABLE_NAME)->where(self::COLUMN_NAME, $username)->fetch(); if (!$row) { throw new Security\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND); } if ($row[self::COLUMN_PASSWORD] !== $this->calculateHash($password, $row[self::COLUMN_PASSWORD])) { throw new Security\AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL); } $arr = $row->toArray(); unset($arr[self::COLUMN_PASSWORD]); return new Nette\Security\Identity($row[self::COLUMN_ID], $row[self::COLUMN_ROLE], $arr); }
public function countAllWithSlug($slug) { return $this->database->table('pages')->where("slug", $slug)->count(); }
public function createAuthenticatorService() { return new Authenticator($this->database->table('users')); }
/** * Získá tabulku číselníků * @return Nette\Database\Table\Selection */ public function getReference($referenceName) { return $this->database->table($referenceName)->order('ordering'); }