public function authenticate($username, $password) { /** @var \stdClass $user */ $user = $this->userModel->getByUsername($username); if (!$user) { throw new Nette\Security\AuthenticationException('Username does not exist.'); } elseif (!Nette\Security\Passwords::verify($password, $user->password)) { throw new Nette\Security\AuthenticationException('The password is incorrect.'); } unset($user->password); return new Nette\Security\Identity($user->id, $user->access, $user); }