diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f193f0a3..c67e141b 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -38,6 +38,11 @@ $routes->get('logout/', 'Authentication::logout'); $routes->get('auth_confirm_mail/', 'Authentication::auth_confirm_mail');//Routes For Confirmation Mail alert page. $routes->get('auth_reset_password/', 'Authentication::auth_reset_password');//Routes For Load Reset password Page. $routes->post('auth_reset_password_save/', 'Authentication::auth_reset_password_save');//Routes For update the Resetted password. +$routes->get('lockscreen/', 'Authentication::lockscreen'); +$routes->get('lock/', 'Authentication::lock'); +$routes->post('unlock/', 'Authentication::unlock'); + + # Dashboard Routes $routes->get('dashboard/', 'Home::index'); diff --git a/app/Controllers/Authentication.php b/app/Controllers/Authentication.php index 0b4bf994..142e7cd1 100755 --- a/app/Controllers/Authentication.php +++ b/app/Controllers/Authentication.php @@ -181,24 +181,26 @@ class Authentication extends BaseController ## Save Resetted password. and Redirect to login public function auth_reset_password_save() { + $auth_model = new AuthenticationModel(); $rules = [ 'password1' => 'required', 'password2' => 'required', ]; if ($this->validate($rules)) { + // echo "try";die; $email = $this->request->getVar('email'); $password = $this->request->getVar('password1'); $confirmation = $this->request->getVar('password2'); $hash_password = password_hash($password, PASSWORD_DEFAULT); - try { + // try { // code for password confirmation if ($password === $confirmation) { $auth_model = new AuthenticationModel(); $user_details = $auth_model->where(['email' => $email, 'isactive' => 1])->first(); if ($user_details) { $update_user_details = ['email' => $email, 'password' => $hash_password]; - $auth_model->update($update_user_details['user_id'], $update_user_details); + $auth_model->update($user_details['user_id'], $update_user_details); } // Retrieve flashed session data $successMessage = session()->getFlashdata('success'); @@ -214,12 +216,12 @@ class Authentication extends BaseController $this->logger->error('Password confirmation failed'); return redirect()->back()->withInput()->with('error', 'Password confirmation failed'); } - } catch (\Exception $e) { - $error = "Exception Errno returned" . $e->getCode() . "
"; - $error_msg = $e->getMessage(); - $this->logger->error($error . '(' . $error_msg . ')'); - return redirect()->back()->withInput()->with('error', $error . '(' . $error_msg . ')'); - } + // } catch (\Exception $e) { + // $error = "Exception Errno returned" . $e->getCode() . "
"; + // $error_msg = $e->getMessage(); + // $this->logger->error($error . '(' . $error_msg . ')'); + // return redirect()->back()->withInput()->with('error', $error . '(' . $error_msg . ')'); + // } } else { // Validation failed, display errors $this->logger->error('Password And Confirmation Password are Required.'); @@ -248,35 +250,51 @@ class Authentication extends BaseController $this->response->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0'); $this->response->setHeader('Pragma', 'no-cache'); $this->response->setHeader('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT'); - - return redirect()->to('/login'); // + $data = []; + return view('auth_logout', $data); } ## Lock Screen - holded public function lockscreen() { // Load the session library - $session = \Config\Services::session(); + helper('session'); + + $session_uid = get_logged_user_id(); + $session_uname = get_logged_name(); + $auth_model = new AuthenticationModel(); + + $details = $auth_model->getheringDetailsForHeader($session_uid); + $data['loggedin_person'] = $session_uname; + $data['loggedin_person_role'] = $details[0]['role']; + $data['favicon'] = $details[0]['favicon']; + $data['profile_picture'] = $details[0]['profile_picture']; + $successMessage = session()->getFlashdata('success'); + $validationErrors = session()->getFlashdata('error'); + // Load and display the form view with the above data + // Here, we'll use the default View class for demonstration purposes // Check if the session is locked - if ($session->get('session_locked')) { + if (get_session_locked()) { + $data['successMessage'] = $successMessage; + $data['validationErrors'] = $validationErrors; // Load the lock screen view - return view('lock_screen'); + return view('auth_lock_screen', $data); } else { // Redirect the user to their previous page or dashboard return redirect()->to('dashboard'); // Replace with appropriate URL } } - ## Lock Screen - holded + ## Lock Screen public function lock() { // Load the session library - $session = \Config\Services::session(); + helper('session'); // Set the session_locked flag - $session->set('session_locked', true); - + set_session_locked(true); + // Redirect the user to the lock screen return redirect()->to('lockscreen'); // Replace with your lock screen URL } @@ -285,26 +303,31 @@ class Authentication extends BaseController public function unlock() { // Load the session library - $session = \Config\Services::session(); + helper('session'); // Check password logic - $password = $this->request->getPost('password'); - + $password = $this->request->getVar('password'); if ($this->checkPassword($password)) { // Unlock the session - $session->remove('session_locked'); + remove_session_locked(); return redirect()->to('dashboard'); // Redirect to dashboard } else { // Incorrect password, show error - return redirect()->back()->with('error', 'Incorrect password.'); + return redirect()->back()->withInput()->with('error', 'Incorrect password.'); } } - ## Unlock Screen - Replace with your password checking logic - holded + ## Unlock Screen private function checkPassword($password) { // Implement your password validation logic here // For example, compare against a stored hash - return $password === 'correct_password'; + // return $password === 'correct_password'; + helper('session'); + $session_uid = get_logged_user_id(); + $auth_model = new AuthenticationModel(); + $user = $auth_model->where('user_id', $session_uid)->first(); + $pwd_verify = password_verify((string)$password, $user['password']); + return $pwd_verify ; } } diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 743c7294..812be8b8 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -72,6 +72,7 @@ abstract class BaseController extends Controller $data['company_name'] = $details[0]['site_name']; $data['company_short_name'] = $details[0]['site_title']; $data['loggedin_person'] = $session_uname; + $data['loggedin_person_id'] = $session_uid; $data['loggedin_person_role'] = $details[0]['role']; $data['favicon'] = $details[0]['favicon']; $data['profile_picture'] = $details[0]['profile_picture']; diff --git a/app/Helpers/session_helper.php b/app/Helpers/session_helper.php index 123cbcba..2e9a3b0d 100644 --- a/app/Helpers/session_helper.php +++ b/app/Helpers/session_helper.php @@ -91,4 +91,28 @@ if (!function_exists('is_session_destroy')) { } } +if (!function_exists('set_session_locked')) { + function set_session_locked() + { + $session = \Config\Services::session(); + $session->set('session_locked', true); + } +} + +if (!function_exists('get_session_locked')) { + function get_session_locked() + { + $session = \Config\Services::session(); + return $session->get('session_locked'); + } +} + +if (!function_exists('remove_session_locked')) { + function remove_session_locked() + { + $session = \Config\Services::session(); + $session->remove('session_locked'); + } +} + ?> \ No newline at end of file diff --git a/app/Views/auth_confirm_mail.php b/app/Views/auth_confirm_mail.php index 0f5491f3..7af74836 100644 --- a/app/Views/auth_confirm_mail.php +++ b/app/Views/auth_confirm_mail.php @@ -33,21 +33,23 @@
- +
diff --git a/app/Views/auth_lock_screen.php b/app/Views/auth_lock_screen.php new file mode 100644 index 00000000..04c39814 --- /dev/null +++ b/app/Views/auth_lock_screen.php @@ -0,0 +1,108 @@ + + + + + Lock Screen + + + + + + "> + + " rel="stylesheet" type="text/css" id="bs-default-stylesheet" /> + " rel="stylesheet" type="text/css" id="app-default-stylesheet" /> + + " rel="stylesheet" type="text/css" id="bs-dark-stylesheet" /> + " rel="stylesheet" type="text/css" id="app-dark-stylesheet" /> + + + " rel="stylesheet" type="text/css" /> + + + + + +
+
+
+
+
+ +
+ + + +
+ " alt="user-image" class="rounded-circle avatar-lg img-thumbnail"> +

+

Enter your password to access the

+
+ +
" method="post"> + +
+ + +
+ + +
+

+
+
+ +
+ +
+ +
+ +
+
+ + +
+
+

Not you? return Sign In

+
+
+ + +
+
+ +
+ +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/auth_login.php b/app/Views/auth_login.php index 2bffa6f6..27d3dbc5 100755 --- a/app/Views/auth_login.php +++ b/app/Views/auth_login.php @@ -38,15 +38,17 @@ " alt="" height="80"> +

BigBambooBookPublish

-

BigBambooBookPublish

Enter your email address and password to access admin panel.

+

Enter your email address and password to access admin panel.

" method="post"> diff --git a/app/Views/auth_logout.php b/app/Views/auth_logout.php index 3938b9af..0b3c1d0a 100755 --- a/app/Views/auth_logout.php +++ b/app/Views/auth_logout.php @@ -2,23 +2,23 @@ - Logout | Minton - Responsive Admin Dashboard Template + Logout - + "> - - + " rel="stylesheet" type="text/css" id="bs-default-stylesheet" /> + " rel="stylesheet" type="text/css" id="app-default-stylesheet" /> - - + " rel="stylesheet" type="text/css" id="bs-dark-stylesheet" /> + " rel="stylesheet" type="text/css" id="app-dark-stylesheet" /> - + " rel="stylesheet" type="text/css" /> @@ -34,16 +34,18 @@
@@ -78,7 +80,7 @@
-

Back to Sign In

+

Back to Sign In

@@ -92,14 +94,14 @@ - + - + \ No newline at end of file diff --git a/app/Views/auth_reset_password.php b/app/Views/auth_reset_password.php index 6187474d..ced9118b 100644 --- a/app/Views/auth_reset_password.php +++ b/app/Views/auth_reset_password.php @@ -37,7 +37,7 @@

Enter your email address and we'll send you an email with instructions to reset your password.

- " method="post" role="form" class="parsley-examples"> + " method="post" role="form" class="parsley-examples">
diff --git a/app/Views/template/topbar.php b/app/Views/template/topbar.php index 38733909..7a5ad2c8 100644 --- a/app/Views/template/topbar.php +++ b/app/Views/template/topbar.php @@ -232,7 +232,7 @@
- + " class="dropdown-item notify-item"> My Account @@ -244,7 +244,7 @@ --> - + " class="dropdown-item notify-item"> Lock Screen