Skip to content

Commit

Permalink
User Automatic Logout
Browse files Browse the repository at this point in the history
If a user is idle on the system it will now automatically log them out
and redirect them to the login page, rather than a crummy error page.
  • Loading branch information
clj13001 committed Apr 11, 2017
1 parent 4da198f commit 66dd230
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions WebContent/html/webpages/navbar.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,29 @@
</div>
<%
Cookie[] usercookies = request.getCookies();
int navsso = 0;
String navsso = "invalid";
String navname = "error";
Cookie newCookie;
//iterate cookies
System.out.println("Cookies:\n----------\n");
for(Cookie c : usercookies){
if(c.getName().equals("ssoNum")){
navsso = Integer.parseInt(c.getValue());
System.out.println(c.getName());
if(c.getName().equals("ssoNum")){//when (and if) we get to user cookie we want to reset it
navsso = c.getValue();
c.setMaxAge(0);//delete current
newCookie = new Cookie("ssoNum",navsso);//make new one
newCookie.setMaxAge(30*60);
response.addCookie(newCookie);
break;
}
}
User self = EmployeeQueries.getEmployeeByID(navsso);
String navname = self.getName();
System.out.println("\nnavsso = "+navsso+"\n");
if(navsso.equals("invalid"))//if we didn't get a cookie, redirect to the homepage to log in again!
response.sendRedirect("../../index.jsp");
else{
User self = EmployeeQueries.getEmployeeByID(Integer.parseInt(navsso));
navname = self.getName();
}
%>
</div>
<script>
Expand Down
2 changes: 1 addition & 1 deletion WebContent/html/webpages/ticketAdminRedirect.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int locationid = Integer.parseInt(locationidstr);
//add form was submitted
if(request.getParameter("approve") != null){
TicketQueries.acceptTicket(ticketid,deviceid,locationid,navsso);
TicketQueries.acceptTicket(ticketid,deviceid,locationid,Integer.parseInt(navsso));
}
//modify form was submitted
if(request.getParameter("reject") != null){
Expand Down

0 comments on commit 66dd230

Please sign in to comment.