Skip to content

Commit

Permalink
I'm just testing something
Browse files Browse the repository at this point in the history
This shouldn't interfere with anything anyone else is doing
  • Loading branch information
arc12012 committed Apr 13, 2017
1 parent f22f1a4 commit 21cf687
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions WebContent/html/webpages/navbar.jspf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<%@ page import = "database.*,entities.User" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">One thing</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../webpages/admin.jsp">
<img src="../imgs/synchrony-financial-logo-dlpx_1.png" style = "height: 100%; display: inline-block;">
&nbsp;&nbsp;&nbsp;&nbsp;
<p style = "display: inline-block" id = "user"></p>
</a>
</div>
<div id="navbar" class="navbar-collapse collapse" aria-expanded="false">
<ul class="nav navbar-nav navbar-right">
<li><a href="../webpages/">Home</a></li>
<li><a href="requestPage.jsp">Request Device</a></li>
<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>
</ul>
</div>
<%
Cookie[] usercookies = request.getCookies();
String navsso = "invalid";
String navname = "error";
Cookie newCookie;
//iterate cookies
System.out.println("Cookies:\n----------\n");
for(Cookie c : usercookies){
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;
}
}
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>
var name = '<%=navname%>';
document.getElementById('user').innerHTML = "Hi " + name + "!";
</script>

0 comments on commit 21cf687

Please sign in to comment.