app/controllers/backend/UserController.php: Adding newAction()
This commit is contained in:
parent
172cddb577
commit
885cdbe47a
1 changed files with 30 additions and 0 deletions
|
|
@ -23,6 +23,36 @@ class UserController extends \Phalcon\Mvc\Controller
|
||||||
$this->view->page = $paginator->getPaginate();
|
$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)
|
public function editAction($id)
|
||||||
{
|
{
|
||||||
$user = User::findFirstById($id);
|
$user = User::findFirstById($id);
|
||||||
|
|
|
||||||
Reference in a new issue