diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php index 43c93b5..a97c7ab 100755 --- a/app/Controllers/Users.php +++ b/app/Controllers/Users.php @@ -472,18 +472,20 @@ class Users extends BaseController $old_password =$this->request->getPost('old_password'); $new_password =$this->request->getPost('new_password'); $confirm_password =$this->request->getPost('confirm_password'); - + $type = $this->request->getPost('type') ?? 'change'; $UsersModel = new UsersModel(); - $user = $UsersModel->where('user_id',$user_id)->first(); - $data_old_password = $user['password']; + if ($type !== 'reset') { + + $user = $UsersModel->where('user_id',$user_id)->first(); + $data_old_password = $user['password']; - if (!password_verify($old_password, $data_old_password)) { - $response = array( - 'status' => 'error', - 'message' => 'Old Password Not Match...' - ); - return json_encode($response); - } + if (!password_verify($old_password, $data_old_password)) { + return $this->response->setJSON([ + 'status' => 'error', + 'message' => 'Old Password does not match.' + ]); + } + } if($new_password != $confirm_password){ $response = array( diff --git a/app/Views/user_form.php b/app/Views/user_form.php index fa1a822..e7b5a98 100755 --- a/app/Views/user_form.php +++ b/app/Views/user_form.php @@ -81,12 +81,24 @@
+ Note: Enable the checkbox to reset the password. Disable it to update the password using existing one. +