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";
     }
 }
Exemplo n.º 2
0
 /**
  * @param \Nette\Application\UI\Form $form
  */
 public function reassignData(Form $form)
 {
     $this->userFacade->setRole($this->id, $form['elections']['role']->getValue());
     $this->userFacade->setSection($this->id, $form['elections']['section']->getValue());
     $password = $form['password']['password']->getValue();
     if ($password) {
         $this->userFacade->edit($this->id, ['password' => $this->passwordHasher->hash($password)]);
     }
 }
Exemplo n.º 3
0
 public function changePassword($id, $password)
 {
     $data = ['password' => $this->passwordHasher->hash($password)];
     $this->userFacade->edit($id, $data);
 }