Archived
1
0
Fork 0

app/controllers/backend/UserController.php: Adding newAction()

This commit is contained in:
Henrik Hautakoski 2022-07-24 23:04:43 +02:00
parent 172cddb577
commit 885cdbe47a

View file

@ -23,6 +23,36 @@ class UserController extends \Phalcon\Mvc\Controller
$this->view->page = $paginator->getPaginate();
}
public function newAction()
{
$user = new User;
$form = new UserSettingsForm($user, true);
if ($this->request->isPost()) {
$data = $this->request->getPost();
if ($form->isValid($data)) {
$new_pw = $form->getValue('passwordNew');
if (strlen($new_pw) > 0) {
$hash = $this->security->hash($new_pw, 12);
$user->setPassword($hash);
}
$form->initialize();
$this->flash->message('success', 'User created!');
$this->response->redirect(['for' => 'backend-user-list']);
return;
}
$this->flash->message('error', 'Could not create user');
}
$this->view->user = $user;
$this->view->form = $form;
$this->view->pick('user/form');
}
public function editAction($id)
{
$user = User::findFirstById($id);