Skip to content

Commit

Permalink
Doesn't Force Login If You're Already Logged In
Browse files Browse the repository at this point in the history
👌
  • Loading branch information
clj13001 committed Apr 12, 2017
1 parent bdf9cd4 commit cb9e346
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
18 changes: 10 additions & 8 deletions WebContent/html/webpages/navbar.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@
User self = new User();
Cookie newCookie;
//iterate cookies
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(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(navsso.equals("invalid"))//if we didn't get a cookie, redirect to the homepage to log in again!
Expand Down
25 changes: 24 additions & 1 deletion WebContent/index.jsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ page import = "database.*" %>
<%@ page import = "database.*,entities.User" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import = "java.sql.*" %>
Expand Down Expand Up @@ -111,3 +111,26 @@
</div>
</body>
</html>

<%
Cookie[] usercookies = request.getCookies();
String navsso = "invalid";
String navname = "error";
User self = new User();
Cookie newCookie;
//iterate cookies
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(navsso.equals("invalid") == false)//if we did get cookie, redirect to the homepage!
response.sendRedirect("html/webpages/index.jsp");
%>

0 comments on commit cb9e346

Please sign in to comment.