From 6ccd07a87013f250378937bbb81de6c5fd8b684b Mon Sep 17 00:00:00 2001 From: Brianna Date: Fri, 14 Apr 2017 13:33:34 -0400 Subject: [PATCH 1/4] Adds logout feature. Users must now input a 9 digit SSO number. --- WebContent/html/webpages/logout.jsp | 21 +++++++++++++++++++++ WebContent/html/webpages/navbar.jsp | 9 ++++----- WebContent/index.jsp | 4 ++-- WebContent/logout.jsp | 20 ++++++++++++++++++++ WebContent/userLogin.jsp | 4 +++- 5 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 WebContent/html/webpages/logout.jsp create mode 100644 WebContent/logout.jsp diff --git a/WebContent/html/webpages/logout.jsp b/WebContent/html/webpages/logout.jsp new file mode 100644 index 0000000..61449b1 --- /dev/null +++ b/WebContent/html/webpages/logout.jsp @@ -0,0 +1,21 @@ +<%@ page import = "database.*,entities.User,utilities.Mail" %> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> +<% +Cookie[] usercookies = request.getCookies(); +if(usercookies != null){ + request.getSession(); + session.removeAttribute("ssoNum"); + session.invalidate(); + for(Cookie c : usercookies){ + if(c.getName().equals("ssoNum")){ + //delete cookies + c.setValue(""); + c.setMaxAge(0); + response.addCookie(c); + } + } + +response.sendRedirect("../../logout.jsp"); +} + +%> \ No newline at end of file diff --git a/WebContent/html/webpages/navbar.jsp b/WebContent/html/webpages/navbar.jsp index 4f60228..54b0dd9 100644 --- a/WebContent/html/webpages/navbar.jsp +++ b/WebContent/html/webpages/navbar.jsp @@ -22,6 +22,7 @@
  • Return Device
  • Device Listing
  • Shopping Cart
  • +
  • Logout <% @@ -33,12 +34,10 @@ //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 + if(c.getName().equals("ssoNum")){//DO NOT RESET COOKIE NO NEW COOKIES NO NEW COOKIES COOKIES CAN'T DELETE IF COOKIES MADE HERE NO NEW COOKIES navsso = c.getValue(); - c.setMaxAge(0);//delete current - newCookie = new Cookie("ssoNum",navsso);//make new one - newCookie.setMaxAge(30*60); - response.addCookie(newCookie); + c.setMaxAge(30*60); + response.addCookie(c); break; } } diff --git a/WebContent/index.jsp b/WebContent/index.jsp index c9e4a6a..61d3a95 100644 --- a/WebContent/index.jsp +++ b/WebContent/index.jsp @@ -95,14 +95,14 @@
  • Home
  • Request Device
  • -
  • Return Device
  • -
  • Device Listing
  • +
  • My Devices
  • +
  • Device Library
  • Shopping Cart
  • Logout
  • @@ -62,5 +62,5 @@ var name = '<%=navname%>'; document.getElementById('user').innerHTML = "Hi " + name + "!"; if(<%=admin%> == 1) -document.getElementById('adminbar').innerHTML = 'Admin Hub' +document.getElementById('adminbar').innerHTML = 'Admin Hub' \ No newline at end of file diff --git a/WebContent/html/webpages/error.jsp b/WebContent/html/webpages/error.jsp index 91076ee..be4cdeb 100644 --- a/WebContent/html/webpages/error.jsp +++ b/WebContent/html/webpages/error.jsp @@ -29,7 +29,7 @@

    Error

    diff --git a/WebContent/html/webpages/index.jsp b/WebContent/html/webpages/index.jsp index 8ccfa57..61b5d3f 100644 --- a/WebContent/html/webpages/index.jsp +++ b/WebContent/html/webpages/index.jsp @@ -42,7 +42,7 @@