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"; } }
/** * @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)]); } }
public function changePassword($id, $password) { $data = ['password' => $this->passwordHasher->hash($password)]; $this->userFacade->edit($id, $data); }