Skip to content

Commit

Permalink
Logout Button Is Functional
Browse files Browse the repository at this point in the history
That was NOT fun.
  • Loading branch information
clj13001 committed Apr 13, 2017
1 parent 99edea5 commit a792c6f
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 16 deletions.
5 changes: 5 additions & 0 deletions WebContent/html/webpages/adminApprove.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,16 @@
.table{
width: auto;
background-color: #E9EAEB;
margin: 0 auto;
}
tbody{
text-align: left;
}
.btn{
margin-top: 15px;
}
</style>
</head>

Expand Down
22 changes: 22 additions & 0 deletions WebContent/html/webpages/logout.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%@ page import = "database.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import = "java.sql.*" %>

<%
Cookie[] usercookies = request.getCookies();
if(usercookies != null){
for(Cookie c : usercookies){
if(c.getName().equals("ssoNum")){//when (and if) we get to user cookie we want to reset it
c.setMaxAge(0);//delete current
Cookie newCookie = new Cookie("ssoNum","");//make new one
newCookie.setMaxAge(0);
newCookie.setPath("/");
response.addCookie(newCookie);
break;
}
}
}
response.sendRedirect("index.jsp");
return;
%>
36 changes: 36 additions & 0 deletions WebContent/html/webpages/logoutPage.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">

<title>Synchrony Financial</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel = "stylesheet" type = "text/css" href = "../css/stylesheet.css">
<link rel = "shortcut icon" href = "../imgs/synchrony-financial-logo-dlpx_1.ico">
<style>
div.error{
text-align: center;
position: absolute;
top: 50%;
left: 50%;
margin-top: -126px;
margin-left: -138px;
}
</style>
</head>

<body>
<div class = "error">
<h2>You Have Logged Out.</h2>
<img src="../imgs/my-icons-collection-128px/png/warning.png"/>
</div>
</body>
</html>
16 changes: 10 additions & 6 deletions WebContent/html/webpages/navbar.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<li><a href="returnPage.jsp">Return Device</a></li>
<li><a href="listingPage.jsp">Device Listing</a></li>
<li><a href="shoppingCart.jsp">Shopping Cart</a></li>
<li><a href="logout.jsp">Logout</a></li>
</ul>
</div>
<%
Expand All @@ -34,12 +35,15 @@
if(usercookies != null){
for(Cookie c : usercookies){
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;
if(c.getValue().equals("") == false){
navsso = c.getValue();
c.setMaxAge(0);//delete current
newCookie = new Cookie("ssoNum",navsso);//make new one
newCookie.setMaxAge(30*60);
newCookie.setPath("/");
response.addCookie(newCookie);
break;
}
}
}
}
Expand Down
14 changes: 5 additions & 9 deletions WebContent/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,11 @@ Cookie newCookie;
if(usercookies != null){
for(Cookie c : usercookies){
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;
if(c.getValue().equals("") == false){
response.sendRedirect("html/webpages/index.jsp");
return;
}
}
}
}
if(navsso.equals("invalid") == false)//if we did get cookie, redirect to the homepage!
response.sendRedirect("html/webpages/index.jsp");
}
%>
3 changes: 2 additions & 1 deletion WebContent/userLogin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ if (result.next()){
session.setAttribute("ssoNum", ssoNum);
userCookie = new Cookie("ssoNum", Integer.toString(ssoNum));
userCookie.setMaxAge(30*60);
userCookie.setPath("/");
response.addCookie(userCookie);
stmt.close();
connection.close();
response.sendRedirect("html/webpages/index.jsp");
} else {
stmt.close();
connection.close();
response.sendRedirect("index.jsp");
response.sendRedirect("html/webpages/index.jsp");
}
%>

0 comments on commit a792c6f

Please sign in to comment.