From 6f4ba689fa46d567eb0f63578cd323f1ae7b262a Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 22 Aug 2023 14:21:53 +0530 Subject: [PATCH] Route fixes : ps --- app/Config/Routes.php | 1 + app/Controllers/Authentication.php | 13 +++++++++---- app/Controllers/Users.php | 4 +++- app/Views/business_list.php | 2 +- app/Views/template/header.php | 6 +++--- app/Views/user.php | 6 ++++-- app/Views/user_list.php | 8 ++++++-- 7 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 773a5842..da66b1fb 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -41,6 +41,7 @@ $routes->get('dashboard/', 'Home::index'); # Users Routes $routes->get("user_list/", "Users::index"); +// $routes->get('user-list/', 'Users::index', ['as' => 'user_list']); $routes->get("user_page/(:any)", "Users::user_page/$1"); $routes->post("user_synchronization", "Users::user_synchronization"); diff --git a/app/Controllers/Authentication.php b/app/Controllers/Authentication.php index 49e40497..285bffa8 100755 --- a/app/Controllers/Authentication.php +++ b/app/Controllers/Authentication.php @@ -32,15 +32,16 @@ class Authentication extends BaseController $password = $this->request->getPost('password'); $user = $auth_model->where('email', $username)->first(); - if (is_null($user)) { return redirect()->back()->with('error', 'Invalid username or password.'); + // return redirect()->back()->withInput()->with('error', 'Invalid username or password.'); } $pwd_verify = password_verify((string)$password, $user['password']); if (!$pwd_verify) { - return redirect()->back()->with('error', 'Invalid username or password.'); + // return redirect()->back()->with('error', 'Invalid username or password.'); + return redirect()->back()->withInput()->with('error', 'Invalid username or password.'); } // You can implement your authentication logic here @@ -60,11 +61,15 @@ class Authentication extends BaseController return redirect()->to('dashboard'); } else { // Invalid credentials, display error message - return redirect()->back()->with('error', 'Invalid username or password.'); + // return redirect()->back()->with('error', 'Invalid username or password.'); + return redirect()->back()->withInput()->with('error', 'Invalid username or password.'); + } } else { // Validation failed, display errors - return redirect()->back()->withInput()->with('validation', $validation); + // return redirect()->back()->withInput()->with('validation', $validation); + return redirect()->back()->withInput()->with('error', 'Invalid username or password.'); + } } diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php index 76976057..1c3586f0 100755 --- a/app/Controllers/Users.php +++ b/app/Controllers/Users.php @@ -58,6 +58,7 @@ class Users extends BaseController $requestData['isactive'] = isset($requestData['isactive']) && $requestData['isactive'] == 'on' ? 1 : 0; unset($requestData['password']); $model->saveData($requestData, $requestData['user_id']); + $alert_message = "User successfully updated."; } else { #add $hash_password = password_hash($requestData['password'], PASSWORD_DEFAULT); @@ -65,7 +66,8 @@ class Users extends BaseController $requestData['created_by'] = $session->get('user_id'); $requestData['isactive'] = 1; $model->saveData($requestData, null); + $alert_message = "User successfully created."; } - return redirect()->route('user_list'); + return redirect()->route('user_list')->with('success', $alert_message); } } diff --git a/app/Views/business_list.php b/app/Views/business_list.php index 575809c5..3d1ac7c6 100644 --- a/app/Views/business_list.php +++ b/app/Views/business_list.php @@ -6,7 +6,7 @@
- Add New + " class="btn btn-primary"> Add New

diff --git a/app/Views/template/header.php b/app/Views/template/header.php index f0001f0f..488f5a11 100644 --- a/app/Views/template/header.php +++ b/app/Views/template/header.php @@ -119,19 +119,19 @@
  • - + "> Users
  • - + "> Books
  • - + "> Business diff --git a/app/Views/user.php b/app/Views/user.php index 7d6a209c..55b1cc6e 100644 --- a/app/Views/user.php +++ b/app/Views/user.php @@ -4,8 +4,10 @@

    -
    " method="post"> - + getFlashdata('success')): ?> +
    getFlashdata('success') ?>
    + + " method="post">
    diff --git a/app/Views/user_list.php b/app/Views/user_list.php index c0a681e3..85488662 100644 --- a/app/Views/user_list.php +++ b/app/Views/user_list.php @@ -3,10 +3,13 @@

    + getFlashdata('success')): ?> +
    getFlashdata('success') ?>
    +
    @@ -35,7 +38,8 @@ $class = 'badge badge-soft-danger'; $message = 'In-Active'; } - $edit_page_route = "user_page/".$row['user_id']; + $edit_page_route = base_url()."user_page/".$row['user_id']; + ?>