1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
3 * Password change controller
5 * op5, and the op5 logo are trademarks, servicemarks, registered servicemarks
6 * or registered trademarks of op5 AB.
7 * All other trademarks, servicemarks, registered trademarks, and registered
8 * servicemarks mentioned herein may be the property of their respective owner(s).
9 * The information contained herein is provided AS IS with NO WARRANTY OF ANY
10 * KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR A
13 class Change_Password_Controller
extends Authenticated_Controller
{
15 public $model = false;
17 public function __construct()
19 parent
::__construct();
20 $this->template
->content
= $this->add_view('change_password/change_password');
21 $this->template
->disable_refresh
= true;
22 $this->template
->title
= _('Configuration ยป Change password');
25 public function index()
27 $this->template
->content
->status_msg
= '';
30 public function change_password()
32 $post = Validation
::factory($_POST);
33 $post->add_rules('*', 'required');
34 $current_password = $this->input
->post('current_password', false);
35 $new_password = $this->input
->post('new_password', false);
36 $new_password2 = $this->input
->post('confirm_password', false);
37 if (strlen($new_password) < 5 ||
strlen($new_password2) < 5)
39 $this->template
->content
->status_msg
= _('The password must be at least 5 chars long.');
41 elseif ($new_password == $new_password2)
43 $auth = Auth
::instance();
44 $user = $auth->get_user();
45 if ($auth->verify_password($user, $current_password))
47 if( $auth->update_password($user, $new_password) ) {
48 $this->template
->content
->status_msg
= _('The password has been changed.');
51 $this->template
->content
->status_msg
= _('Authentication backend reported that password could not be updated.');
55 $this->template
->content
->status_msg
= _('You entered incorrect current password.');
59 $this->template
->content
->status_msg
= _('Passwords do not match.');