Browse Source

logout after 10 minutes of inactive

master
AJITHKUMAR12 1 year ago
parent
commit
863405e4f6
  1. 16
      src/main/java/com/gcc/crslogs/controller/MainController.java
  2. 3
      src/main/resources/templates/modules/crslogspages/birth.html
  3. 13
      src/main/resources/templates/modules/crslogspages/death.html

16
src/main/java/com/gcc/crslogs/controller/MainController.java

@ -13,15 +13,17 @@ import jakarta.servlet.http.HttpSession;
@RequestMapping(value = { "/crs" })
public class MainController {
@GetMapping(value = { "", "/", "/birthloginpage","/deathloginpage" })
public String requestbirthform(Model model) {
@GetMapping("/birthloginpage")
public String requestBirthForm(Model model) {
return "modules/crslogspages/birthloginpage";
}
public String requestdeathform(Model model) {
@GetMapping("/deathloginpage")
public String requestDeathForm(Model model) {
return "modules/crslogspages/deathloginpage";
}
/*@GetMapping("/birthanddeath")
public String birthform(HttpServletRequest request, Model model) {
HttpSession session = request.getSession();
@ -42,7 +44,7 @@ public class MainController {
@GetMapping("/birth")
public String birthPage(HttpServletRequest request, Model model) {
HttpSession session = request.getSession();
session.setMaxInactiveInterval(10 * 60);
String username = (String) session.getAttribute("userName");
if (username == null || username.isEmpty()) {
return "modules/crslogspages/birthloginpage";
@ -54,7 +56,7 @@ public class MainController {
@GetMapping("/death")
public String deathPage(HttpServletRequest request, Model model) {
HttpSession session = request.getSession();
session.setMaxInactiveInterval(10 * 60);
String username = (String) session.getAttribute("userName");
if (username == null || username.isEmpty()) {
return "modules/crslogspages/deathloginpage";
@ -67,7 +69,7 @@ public class MainController {
@GetMapping("/birthlogout")
public String logoutbirthForm(HttpServletRequest request) {
HttpSession session = request.getSession();
session.setMaxInactiveInterval(10 * 60);
session.invalidate();
return "modules/crslogspages/birth";

3
src/main/resources/templates/modules/crslogspages/birth.html

@ -770,6 +770,7 @@ body {
// Redirect after 60 seconds (1 minute) of inactivity
let timeoutDuration = 10 * 60 * 1000; // 60 seconds
//let timeoutDuration = 1 * 60 * 1000; // 1 minute = 60,000 ms
let timeout;
@ -777,7 +778,7 @@ body {
clearTimeout(timeout);
timeout = setTimeout(() => {
// Optionally check if session is still active via an API
window.location.href = "/crs/loginpage";
window.location.href = "/crs/birthloginpage";
}, timeoutDuration);
}

13
src/main/resources/templates/modules/crslogspages/death.html

@ -249,7 +249,7 @@ body {
.nav-link.active {
color: white;
background-color: #007bff;
background-color: #006680;
border-radius: 5px;
padding: 5px 10px;
font-weight: bold;
@ -284,8 +284,8 @@ body {
transition: background-color 0.3s ease;
}
.nav-link:hover,
.nav-link.active {
.nav-link:hover
{
background-color: #006680;
color: #fff;
}
@ -490,7 +490,7 @@ body {
<nav class="nav-bar">
<ul class="nav-list">
<!-- <li><a id="birth-link" class="nav-link active">Birth</a></li>-->
<li><a id="death-link" class="nav-link">Death</a></li>
<li><a id="death-link" class="nav-link active">Death</a></li>
</ul>
</nav>
@ -771,13 +771,16 @@ body {
// Redirect after 60 seconds (1 minute) of inactivity
let timeoutDuration = 10 * 60 * 1000; // 60 seconds
// 1 minute = 60,000 ms
let timeout;
function resetTimeout() {
clearTimeout(timeout);
timeout = setTimeout(() => {
// Optionally check if session is still active via an API
window.location.href = "/crs/loginpage";
window.location.href = "/crs/deathloginpage";
}, timeoutDuration);
}

Loading…
Cancel
Save