From bfd59d9e544028a1ea041806fd60e112f3a90167 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 18 May 2016 21:27:36 -0400 Subject: Reset failed login counter and unlock user when changing password --- app/Controller/UserModificationController.php | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 app/Controller/UserModificationController.php (limited to 'app/Controller/UserModificationController.php') diff --git a/app/Controller/UserModificationController.php b/app/Controller/UserModificationController.php new file mode 100644 index 00000000..0a50eb5b --- /dev/null +++ b/app/Controller/UserModificationController.php @@ -0,0 +1,69 @@ +getUser(); + + if (empty($values)) { + $values = $user; + unset($values['password']); + } + + return $this->response->html($this->helper->layout->user('user_modification/show', array( + 'values' => $values, + 'errors' => $errors, + 'user' => $user, + 'timezones' => $this->timezone->getTimezones(true), + 'languages' => $this->language->getLanguages(true), + 'roles' => $this->role->getApplicationRoles(), + ))); + } + + /** + * Save user information + */ + public function save() + { + $user = $this->getUser(); + $values = $this->request->getValues(); + + if (! $this->userSession->isAdmin()) { + if (isset($values['role'])) { + unset($values['role']); + } + } + + list($valid, $errors) = $this->userValidator->validateModification($values); + + if ($valid) { + if ($this->user->update($values)) { + $this->flash->success(t('User updated successfully.')); + } else { + $this->flash->failure(t('Unable to update your user.')); + } + + return $this->response->redirect($this->helper->url->to('UserViewController', 'show', array('user_id' => $user['id']))); + } + + return $this->show($values, $errors); + } +} -- cgit v1.2.3