public function authenticate(array $credentials) { list($username, $password) = $credentials; $context = $this->userFacade->all(); $this->userFilter->filterUsername($context, $username); $user = $context->fetch(); if (!$user) { throw new Security\AuthenticationException("User {$username} not found"); } if (!$this->passwordVerifier->verify($password, $user['password'])) { throw new Security\AuthenticationException("Wrong password for user {$username}"); } $data = ['username' => $user['username'], 'name' => $user['name'], 'surname' => $user['surname'], 'super' => $this->isSuperRole($user['id']), 'sections' => $this->getSections($user['id'])]; return new Security\Identity($user['id'], $this->getRoles($user['id']), $data); }
/** * @param \Nette\Application\UI\Form $form */ private function checkUsername(Form $form) { $username = $form['base']['username']->getValue(); $user = $this->userFilter->filterUsername($this->userFacade->all(), $username)->fetch(); if (!$user) { return; } if (!($user->id == $this->id)) { $form->addError('Zadaný login již existuje, zadejte prosím jiný'); } }
/** * @param $username * @return \Nette\Database\Table\Selection */ public function username($username) { return $this->userFilter->filterUsername($this->all(), $username); }