/** * @param $name * @param $password * @return User|null * @throws Exception */ public function auth($name, $password) { $id = $this->getIdByName($name); if (!$id) { throw new Exception("User with name {$name} not found"); } $User = Kernel::getRepository(EntityType::USER)->loadById($id); if (password_verify($password, $User->get(User::FIELD_PASSWORD))) { return $User; } return null; }
/** * @return PostRepository */ protected function getRepository() { return Kernel::getRepository(EntityType::POST); }