protected function createUser($username, $password, $role, $name, $surname)
 {
     try {
         $data = ['username' => $username, 'password' => $this->passwordHasher->hash($password), 'role' => $role, 'name' => $name, 'surname' => $surname];
         $user = $this->userFacade->add($data);
         $id = $user['id'];
         echo "User created with ID {$id}\n";
     } catch (\Esports\PrimaryKeyException $e) {
         echo "User {$username} already exists!\n";
     }
 }
Пример #2
0
 /**
  * @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ý');
     }
 }
Пример #3
0
 /**
  * @return Nette\Application\IRouter
  */
 public static function createRouter(ArticleFacade $articleFacade, CategoryFacade $categoryFacade, TagFacade $tagFacade, UserFacade $authorFacade)
 {
     $router = new RouteList();
     $router[] = $signRouter = new RouteList("Sign");
     $signRouter[] = new Route("odhlaseni", "Sign:out");
     $router[] = $adminRouter = new RouteList("Admin");
     $adminRouter[] = new Route("admin/<presenter>/<action>[/<id>]", "Homepage:default");
     $router[] = $frontRouter = new RouteList("Front");
     $frontRouter[] = new Route("kontakt", "Contact:default");
     $frontRouter[] = new Route("vseobecne-podminky", "Conditions:default");
     $frontRouter[] = new Route("registrace", "Registration:default");
     $frontRouter[] = new Route("zapomenute-heslo", "ForgottenPassword:default");
     $frontRouter[] = new Route("clanek/<id>", array("presenter" => "Article", "action" => "default", "id" => array(Route::FILTER_IN => function ($url) use($articleFacade) {
         if (is_numeric($url)) {
             return $url;
         } else {
             $article = $articleFacade->findIdByUrl($url);
             if ($article) {
                 return $article->id;
             } else {
                 return NULL;
             }
         }
     }, Route::FILTER_OUT => function ($id) use($articleFacade) {
         if (!is_numeric($id)) {
             return $id;
         } else {
             $article = $articleFacade->findUrlById($id);
             if ($article) {
                 return $article->url;
             } else {
                 return NULL;
             }
         }
     })));
     $frontRouter[] = new Route("autor/<id>", array("presenter" => "Author", "action" => "default", "id" => array(Route::FILTER_IN => function ($url) use($authorFacade) {
         if (is_numeric($url)) {
             return $url;
         } else {
             $author = $authorFacade->findIdByUrl($url);
             if ($author) {
                 return $author->id;
             } else {
                 return NULL;
             }
         }
     }, Route::FILTER_OUT => function ($id) use($authorFacade) {
         if (!is_numeric($id)) {
             return $id;
         } else {
             $author = $authorFacade->findUrlById($id);
             if ($author) {
                 return $author->url;
             } else {
                 return NULL;
             }
         }
     })));
     $frontRouter[] = new Route("tag/<id>", array("presenter" => "Tag", "action" => "default", "id" => array(Route::FILTER_IN => function ($url) use($tagFacade) {
         if (is_numeric($url)) {
             return $url;
         } else {
             $tag = $tagFacade->findIdByUrl($url);
             if ($tag) {
                 return $tag->id;
             } else {
                 return NULL;
             }
         }
     }, Route::FILTER_OUT => function ($id) use($tagFacade) {
         if (!is_numeric($id)) {
             return $id;
         } else {
             $tag = $tagFacade->findUrlById($id);
             if ($tag) {
                 return $tag->url;
             } else {
                 return NULL;
             }
         }
     })));
     $frontRouter[] = new Route("kategorie/<id>", array("presenter" => "Category", "action" => "default", "id" => array(Route::FILTER_IN => function ($url) use($categoryFacade) {
         if (is_numeric($url)) {
             return $url;
         } else {
             $category = $categoryFacade->findIdByUrl($url);
             if ($category) {
                 return $category->id;
             } else {
                 return NULL;
             }
         }
     }, Route::FILTER_OUT => function ($id) use($categoryFacade) {
         if (!is_numeric($id)) {
             return $id;
         } else {
             $category = $categoryFacade->findUrlById($id);
             if ($category) {
                 return $category->url;
             } else {
                 return NULL;
             }
         }
     })));
     $frontRouter[] = new Route("<presenter>/<action>[/<id>]", "Homepage:default");
     return $router;
 }
 /**
  * @param $id
  * @return array
  */
 protected function getSections($id)
 {
     $selection = $this->userFilter->filterId($this->userFacade->all(), $id);
     $selection->select(':user_has_section.section.id');
     return $selection->fetchPairs('id', 'id');
 }
Пример #5
0
 /**
  * @param int $id
  */
 public function delete($id)
 {
     $this->userFacade->delete($id);
 }
Пример #6
0
 public function changePassword($id, $password)
 {
     $data = ['password' => $this->passwordHasher->hash($password)];
     $this->userFacade->edit($id, $data);
 }