From 562153c2d073ce038c42c324f8d3339eb06aa470 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 7 Jan 2025 17:00:03 +0530 Subject: [PATCH 1/8] FEAT_COOKIE DATA SAVE AND VERIFY ADDED - SRINIVAS --- app/Controllers/LoginController.php | 16 +++++++----- app/Filters/AuthMVC.php | 2 +- app/Helpers/session_helper.php | 36 +++++++++++++++++++++++++- app/Views/test_members_list.php | 39 +++++++++++++++++++++++------ 4 files changed, 77 insertions(+), 16 deletions(-) diff --git a/app/Controllers/LoginController.php b/app/Controllers/LoginController.php index 10c42716..b3ca2187 100755 --- a/app/Controllers/LoginController.php +++ b/app/Controllers/LoginController.php @@ -19,17 +19,16 @@ class LoginController extends BaseController // set_session_data($session_data); // $isLoggedIn = check_session(); $isLoggedIn = check_session(); - - if ($isLoggedIn) { + $hasCookie = check_cookie(); + if ($isLoggedIn || $hasCookie) { return redirect()->to(base_url('/dashboard/view')); } return view('login'); } - + public function receiveGoogleOAuthResponse() { - $UserModel = new UserModel(); //echo 'DONE';die(); if ($this->request->getGet('code')) { @@ -52,7 +51,10 @@ class LoginController extends BaseController 'userProfile' => $value->picture, 'user_team' => $user_team, ]; - + $path = getenv('cookie.Path'); + $domain = getenv('cookie.Domain'); + $https = getenv('ccokie.secure'); + setcookie('session_data', json_encode($session_data), time() + 12 * 60 * 60, $path, $domain, $https, true); set_session_data($session_data); log_message('error', 'Set The UserId : `'. $user->id .'` in Session'); @@ -82,12 +84,14 @@ class LoginController extends BaseController public function initiateGoogleOAuth() { - return googleOAuthLogin(false); + return googleOAuthLogin(false); } public function logout() { + $path = getenv('cookie.Path'); session()->destroy(); + setcookie('session_data', '', time() - 3600, $path); return redirect()->to(base_url('login')); } diff --git a/app/Filters/AuthMVC.php b/app/Filters/AuthMVC.php index aa406108..1e0be969 100755 --- a/app/Filters/AuthMVC.php +++ b/app/Filters/AuthMVC.php @@ -9,7 +9,7 @@ class AuthMVC implements FilterInterface { public function before(RequestInterface $request, $arguments = null) { - if (!check_session()) { + if (!check_session() && !check_cookie()) { return redirect()->to(base_url('/login')); } diff --git a/app/Helpers/session_helper.php b/app/Helpers/session_helper.php index 4a13df4d..f5c6e513 100755 --- a/app/Helpers/session_helper.php +++ b/app/Helpers/session_helper.php @@ -1,5 +1,39 @@ getUserByEmail($value['userData']->email); + if($user){ + if($user->is_active !== '0'){ + $user_team = $UserModel->getUserTeamsByUserID($user->id); + // dd($user_team); + + $session_data = [ + 'isLoggedIn' => True , + 'userid' => $user->id, + 'userData' => $user, + 'userProfile' => $value['userProfile'], + 'user_team' => $user_team, + ]; + set_session_data($session_data); + // $this->getUserDeviceInfo($user->id, 'NhanceUser'); + // return redirect()->to(base_url('/dashboard/view')); + return true; + + } + // $session_data = (array)json_decode($_COOKIE['session_data']); + // set_session_data($session_data); + } + }else{ + return false; + } +} if (!function_exists('check_session')) { function check_session() @@ -150,7 +184,7 @@ if (!function_exists('user_team')) { } - +} diff --git a/app/Views/test_members_list.php b/app/Views/test_members_list.php index 385aeb37..aaaf425e 100644 --- a/app/Views/test_members_list.php +++ b/app/Views/test_members_list.php @@ -87,6 +87,27 @@ color: #16181b !important; cursor: pointer !important; } +th, td { + text-align: center; /* Or left/right depending on your preference */ + vertical-align: middle; /* Ensures content is vertically centered */ +} +input[type="checkbox"] { + width: 16px; /* Standard checkbox size */ + height: 16px; + margin: 0; /* Remove default margin */ + vertical-align: middle; /* Align with text or other elements */ +} +th:first-child, td:first-child { + width: 50px; /* Adjust width as needed */ +} +.table-responsive { + overflow-x: auto; +} + +.table { + table-layout: fixed; /* Prevent columns from resizing dynamically */ +} + @@ -156,12 +177,13 @@ + - - + } --> + */ + ?> @@ -392,7 +415,7 @@