From f7db3c45131b456714bda0272e0c104fccb23081 Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Thu, 13 Nov 2025 09:21:21 +0530 Subject: [PATCH] FIX_Reset password Implemented --- app/Controllers/Users.php | 22 +++++---- app/Views/user_form.php | 96 +++++++++++++++++++++++++++++++-------- 2 files changed, 90 insertions(+), 28 deletions(-) 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 @@
-
Change Password
+
Change / Reset Password
+

+ Note: Enable the checkbox to reset the password. Disable it to update the password using existing one. +

-
+
+
+ + +
+
+ +