Lock Screen : ps

This commit is contained in:
VE10-Sanjeev 2023-09-02 19:19:40 +05:30
parent afb56f06b0
commit a0d3e4bef1
10 changed files with 218 additions and 51 deletions

View File

@ -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_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->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->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 # Dashboard Routes
$routes->get('dashboard/', 'Home::index'); $routes->get('dashboard/', 'Home::index');

View File

@ -181,24 +181,26 @@ class Authentication extends BaseController
## Save Resetted password. and Redirect to login ## Save Resetted password. and Redirect to login
public function auth_reset_password_save() public function auth_reset_password_save()
{ {
$auth_model = new AuthenticationModel(); $auth_model = new AuthenticationModel();
$rules = [ $rules = [
'password1' => 'required', 'password1' => 'required',
'password2' => 'required', 'password2' => 'required',
]; ];
if ($this->validate($rules)) { if ($this->validate($rules)) {
// echo "try";die;
$email = $this->request->getVar('email'); $email = $this->request->getVar('email');
$password = $this->request->getVar('password1'); $password = $this->request->getVar('password1');
$confirmation = $this->request->getVar('password2'); $confirmation = $this->request->getVar('password2');
$hash_password = password_hash($password, PASSWORD_DEFAULT); $hash_password = password_hash($password, PASSWORD_DEFAULT);
try { // try {
// code for password confirmation // code for password confirmation
if ($password === $confirmation) { if ($password === $confirmation) {
$auth_model = new AuthenticationModel(); $auth_model = new AuthenticationModel();
$user_details = $auth_model->where(['email' => $email, 'isactive' => 1])->first(); $user_details = $auth_model->where(['email' => $email, 'isactive' => 1])->first();
if ($user_details) { if ($user_details) {
$update_user_details = ['email' => $email, 'password' => $hash_password]; $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 // Retrieve flashed session data
$successMessage = session()->getFlashdata('success'); $successMessage = session()->getFlashdata('success');
@ -214,12 +216,12 @@ class Authentication extends BaseController
$this->logger->error('Password confirmation failed'); $this->logger->error('Password confirmation failed');
return redirect()->back()->withInput()->with('error', 'Password confirmation failed'); return redirect()->back()->withInput()->with('error', 'Password confirmation failed');
} }
} catch (\Exception $e) { // } catch (\Exception $e) {
$error = "Exception Errno returned" . $e->getCode() . " <br/>"; // $error = "Exception Errno returned" . $e->getCode() . " <br/>";
$error_msg = $e->getMessage(); // $error_msg = $e->getMessage();
$this->logger->error($error . '(' . $error_msg . ')'); // $this->logger->error($error . '(' . $error_msg . ')');
return redirect()->back()->withInput()->with('error', $error . '(' . $error_msg . ')'); // return redirect()->back()->withInput()->with('error', $error . '(' . $error_msg . ')');
} // }
} else { } else {
// Validation failed, display errors // Validation failed, display errors
$this->logger->error('Password And Confirmation Password are Required.'); $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('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
$this->response->setHeader('Pragma', 'no-cache'); $this->response->setHeader('Pragma', 'no-cache');
$this->response->setHeader('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT'); $this->response->setHeader('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT');
$data = [];
return redirect()->to('/login'); // return view('auth_logout', $data);
} }
## Lock Screen - holded ## Lock Screen - holded
public function lockscreen() public function lockscreen()
{ {
// Load the session library // 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 // 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 // Load the lock screen view
return view('lock_screen'); return view('auth_lock_screen', $data);
} else { } else {
// Redirect the user to their previous page or dashboard // Redirect the user to their previous page or dashboard
return redirect()->to('dashboard'); // Replace with appropriate URL return redirect()->to('dashboard'); // Replace with appropriate URL
} }
} }
## Lock Screen - holded ## Lock Screen
public function lock() public function lock()
{ {
// Load the session library // Load the session library
$session = \Config\Services::session(); helper('session');
// Set the session_locked flag // Set the session_locked flag
$session->set('session_locked', true); set_session_locked(true);
// Redirect the user to the lock screen // Redirect the user to the lock screen
return redirect()->to('lockscreen'); // Replace with your lock screen URL return redirect()->to('lockscreen'); // Replace with your lock screen URL
} }
@ -285,26 +303,31 @@ class Authentication extends BaseController
public function unlock() public function unlock()
{ {
// Load the session library // Load the session library
$session = \Config\Services::session(); helper('session');
// Check password logic // Check password logic
$password = $this->request->getPost('password'); $password = $this->request->getVar('password');
if ($this->checkPassword($password)) { if ($this->checkPassword($password)) {
// Unlock the session // Unlock the session
$session->remove('session_locked'); remove_session_locked();
return redirect()->to('dashboard'); // Redirect to dashboard return redirect()->to('dashboard'); // Redirect to dashboard
} else { } else {
// Incorrect password, show error // 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) private function checkPassword($password)
{ {
// Implement your password validation logic here // Implement your password validation logic here
// For example, compare against a stored hash // 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 ;
} }
} }

View File

@ -72,6 +72,7 @@ abstract class BaseController extends Controller
$data['company_name'] = $details[0]['site_name']; $data['company_name'] = $details[0]['site_name'];
$data['company_short_name'] = $details[0]['site_title']; $data['company_short_name'] = $details[0]['site_title'];
$data['loggedin_person'] = $session_uname; $data['loggedin_person'] = $session_uname;
$data['loggedin_person_id'] = $session_uid;
$data['loggedin_person_role'] = $details[0]['role']; $data['loggedin_person_role'] = $details[0]['role'];
$data['favicon'] = $details[0]['favicon']; $data['favicon'] = $details[0]['favicon'];
$data['profile_picture'] = $details[0]['profile_picture']; $data['profile_picture'] = $details[0]['profile_picture'];

View File

@ -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');
}
}
?> ?>

View File

@ -33,21 +33,23 @@
<div class="card-body p-4"> <div class="card-body p-4">
<!-- <div class="text-center w-75 m-auto"> <div class="text-center w-75 m-auto">
<div class="auth-logo"> <div class="auth-logo">
<a href="index.html" class="logo logo-dark text-center"> <a href="javascript:void(0);" class="logo logo-dark text-center">
<span class="logo-lg"> <span class="logo-lg">
<img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="22"> <img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="55">
</span> </span>
<p class="text-muted"><span>BigBambooBookPublish</p>
</a> </a>
<a href="index.html" class="logo logo-light text-center"> <a href="javascript:void(0);" class="logo logo-light text-center">
<span class="logo-lg"> <span class="logo-lg">
<img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="22"> <img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="55">
</span> </span>
<p class="text-muted"><span>BigBambooBookPublish</p>
</a> </a>
</div> </div>
</div> --> </div>
<div class="mt-3 text-center"> <div class="mt-3 text-center">
<svg version="1.1" xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 98 98" style="height: 120px;" xml:space="preserve"> <svg version="1.1" xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 98 98" style="height: 120px;" xml:space="preserve">

View File

@ -0,0 +1,108 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Lock Screen </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?= base_url() . "public/assets/images/company/default.ico" ?>">
<!-- App css -->
<link href="<?= base_url() . "public/assets/css/bootstrap.min.css" ?>" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app.min.css" ?>" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url() . "public/assets/css/bootstrap-dark.min.css" ?>" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url() . "public/assets/css/app-dark.min.css" ?>" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- icons -->
<link href="<?= base_url() . "public/assets/css/icons.min.css" ?>" rel="stylesheet" type="text/css" />
</head>
<body class="loading">
<div class="account-pages mt-5 mb-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-6 col-xl-5">
<div class="card">
<div class="card-body p-4">
<div class="text-center mb-4">
<div class="auth-logo">
<a href="javascript:void(0);" class="logo logo-dark text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="55">
</span>
<p class="text-muted"><span>BigBambooBookPublish</p>
</a>
<a href="javascript:void(0);" class="logo logo-light text-center">
<span class="logo-lg">
<img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="55">
</span>
<p class="text-muted"><span>BigBambooBookPublish</p>
</a>
</div>
</div>
<div class="text-center w-75 m-auto">
<img src="<?= base_url()."public/assets/images/users/".$profile_picture; ?>" alt="user-image" class="rounded-circle avatar-lg img-thumbnail">
<h4 class="text-dark-50 text-center mt-3"><?= 'Hi ! '.$loggedin_person; ?></h4>
<p class="text-muted mb-4">Enter your password to access the <?= $loggedin_person_role; ?></p>
</div>
<form action="<?= base_url() . "unlock" ?>" method="post">
<div class="form-group mb-3">
<label for="password">Password</label>
<input class="form-control" type="password" required="" id="password" name="password" placeholder="Enter your password">
</div>
<?php if (isset($validationErrors)) : ?>
<span class="widget-simple text-center">
<div class="media-body align-self-center font-24 avatar-title">
<p style="color: #f1556c!important;" class="mt-0" style><?= $validationErrors; ?></p>
</div>
</span>
<?php endif; ?>
<div class="form-group mb-0 text-center">
<button class="btn btn-primary btn-block" type="submit"> Log In </button>
</div>
</form>
</div> <!-- end card-body -->
</div>
<!-- end card -->
<div class="row mt-3">
<div class="col-12 text-center">
<p class="text-muted">Not you? return <a href="<?= base_url(); ?>" class="text-primary font-weight-medium ml-1">Sign In</a></p>
</div> <!-- end col -->
</div>
<!-- end row -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
<footer class="footer footer-alt">
<p> <?= date('Y') ?> &copy; <?= "bigbamboobookpublish"; ?>.</p>
</footer>
<!-- Vendor js -->
<script src="<?= base_url() . "public/assets/js/vendor.min.js" ?>" ></script>
<!-- App js -->
<script src="<?= base_url() . "public/assets/js/app.min.js" ?>" ></script>
</body>
</html>

View File

@ -38,15 +38,17 @@
<span class="logo-lg"> <span class="logo-lg">
<img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="80"> <img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="80">
</span> </span>
<p class="text-muted"><span>BigBambooBookPublish</p>
</a> </a>
<a href="javascript: void(0);" class="logo logo-light text-center"> <a href="javascript: void(0);" class="logo logo-light text-center">
<span class="logo-lg"> <span class="logo-lg">
<img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="80"> <img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="80">
</span> </span>
<p class="text-muted"><span>BigBambooBookPublish</p>
</a> </a>
</div> </div>
<p class="text-muted mb-4 mt-3"><span>BigBambooBookPublish</br></br></span>Enter your email address and password to access admin panel.</p> <p class="text-muted mb-4 mt-3">Enter your email address and password to access admin panel.</p>
</div> </div>
<!-- <form action=""> --> <!-- <form action=""> -->
<form action="<?= base_url() . "authenticate" ?>" method="post"> <form action="<?= base_url() . "authenticate" ?>" method="post">

View File

@ -2,23 +2,23 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>Logout | Minton - Responsive Admin Dashboard Template</title> <title>Logout </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" /> <meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" /> <meta content="Coderthemes" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon --> <!-- App favicon -->
<link rel="shortcut icon" href="../assets/images/favicon.ico"> <link rel="shortcut icon" href="<?= base_url() . "public/assets/images/company/default.ico" ?>">
<!-- App css --> <!-- App css -->
<link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" id="bs-default-stylesheet" /> <link href="<?= base_url() . "public/assets/css/bootstrap.min.css"?>" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="../assets/css/app.min.css" rel="stylesheet" type="text/css" id="app-default-stylesheet" /> <link href="<?= base_url() . "public/assets/css/app.min.css"?>" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="../assets/css/bootstrap-dark.min.css" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" /> <link href="<?= base_url() . "public/assets/css/bootstrap-dark.min.css"?>" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="../assets/css/app-dark.min.css" rel="stylesheet" type="text/css" id="app-dark-stylesheet" /> <link href="<?= base_url() . "public/assets/css/app-dark.min.css"?>" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- icons --> <!-- icons -->
<link href="../assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <link href="<?= base_url() . "public/assets/css/icons.min.css"?>" rel="stylesheet" type="text/css" />
</head> </head>
@ -34,16 +34,18 @@
<div class="text-center w-75 m-auto"> <div class="text-center w-75 m-auto">
<div class="auth-logo"> <div class="auth-logo">
<a href="index.html" class="logo logo-dark text-center"> <a href="javascript:void(0);" class="logo logo-dark text-center">
<span class="logo-lg"> <span class="logo-lg">
<img src="../assets/images/logo-dark.png" alt="" height="22"> <img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="55">
</span> </span><br/>
<p class="text-muted"><span>BigBambooBookPublish</p>
</a> </a>
<a href="index.html" class="logo logo-light text-center"> <a href="javascript:void(0);" class="logo logo-light text-center">
<span class="logo-lg"> <span class="logo-lg">
<img src="../assets/images/logo-light.png" alt="" height="22"> <img src="<?= base_url() . "public/assets/images/company/default.png" ?>" alt="" height="55">
</span> </span><br/>
<p class="text-muted"><span>BigBambooBookPublish</p>
</a> </a>
</div> </div>
</div> </div>
@ -78,7 +80,7 @@
<div class="row mt-3"> <div class="row mt-3">
<div class="col-12 text-center"> <div class="col-12 text-center">
<p class="text-muted">Back to <a href="authenticate" class="text-primary font-weight-medium ml-1">Sign In</a></p> <p class="text-muted">Back to <a href="<?= base_url(); ?>" class="text-primary font-weight-medium ml-1">Sign In</a></p>
</div> <!-- end col --> </div> <!-- end col -->
</div> </div>
<!-- end row --> <!-- end row -->
@ -92,14 +94,14 @@
<!-- end page --> <!-- end page -->
<footer class="footer footer-alt"> <footer class="footer footer-alt">
<script>document.write(new Date().getFullYear())</script> &copy; Minton theme by <a href="" class="text-dark">Coderthemes</a> <p> <?= date('Y') ?> &copy; <?= "bigbamboobookpublish"; ?>.</p>
</footer> </footer>
<!-- Vendor js --> <!-- Vendor js -->
<script src="../assets/js/vendor.min.js"></script> <script src="<?= base_url() . "public/assets/js/vendor.min.js" ?>"></script>
<!-- App js --> <!-- App js -->
<script src="../assets/js/app.min.js"></script> <script src="<?= base_url() . "public/assets/js/app.min.js" ?>"></script>
</body> </body>
</html> </html>

View File

@ -37,7 +37,7 @@
<p class="text-muted mb-4 mt-3">Enter your email address and we'll send you an email with instructions to reset your password.</p> <p class="text-muted mb-4 mt-3">Enter your email address and we'll send you an email with instructions to reset your password.</p>
</div> </div>
<form action="<?= base_url() . "auth_reset_password_save" ?>" method="post" role="form" class="parsley-examples"> <form action="<?= base_url()."auth_reset_password_save"?>" method="post" role="form" class="parsley-examples">
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-2 col-form-label" for="emailaddress">Email : </label> <label class="col-sm-2 col-form-label" for="emailaddress">Email : </label>
<div class="col-sm-10"> <div class="col-sm-10">

View File

@ -232,7 +232,7 @@
</div> </div>
<!-- item--> <!-- item-->
<a href="user_list" class="dropdown-item notify-item"> <a href="<?= base_url()."user_page/".$loggedin_person_id; ?>" class="dropdown-item notify-item">
<i class="ri-account-circle-line"></i> <i class="ri-account-circle-line"></i>
<span>My Account</span> <span>My Account</span>
</a> </a>
@ -244,7 +244,7 @@
</a> --> </a> -->
<!-- item--> <!-- item-->
<a href="javascript:void(0);" class="dropdown-item notify-item"> <a href="<?= base_url()."lock"; ?>" class="dropdown-item notify-item">
<i class="ri-lock-line"></i> <i class="ri-lock-line"></i>
<span>Lock Screen</span> <span>Lock Screen</span>
</a> </a>