From 3e38c8ca41790d591021d846c0d65470e96f0044 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 1 Apr 2018 10:10:24 +0200 Subject: [PATCH] adding app/controllers/UserController.php --- app/controllers/UserController.php | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/controllers/UserController.php diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php new file mode 100644 index 0000000..76d98f3 --- /dev/null +++ b/app/controllers/UserController.php @@ -0,0 +1,34 @@ +_getAuth()->getUser(); + + $form = new UserSettingsForm($user); + + if ($this->request->isPost()) { + $data = $this->request->getPost(); + + if ($form->isValid($data)) { + + $new_pw = $form->getValue('passwordNew'); + if (strlen($new_pw) > 0) { + $hash = password_hash($new_pw, PASSWORD_BCRYPT); + $user->setPassword($hash); + } + $user->save(); + $form->initialize(); + + $this->flash->message('success', 'Settings saved!'); + } else { + $this->flash->message('error', 'Could not save settings'); + } + } + + $this->view->form = $form; + } +}