Skip to content

Bugs #140

Merged
merged 3 commits into from
Apr 19, 2017
Merged

Bugs #140

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion WebContent/adminLogin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(database, user, password);
Statement stmt = connection.createStatement();
ResultSet result;
result = stmt.executeQuery("select * FROM admin where Admin_ID='" + ssoNum + "' AND Password='" + generatedPass + "'");
result = stmt.executeQuery("select admin.*,employee.Name FROM admin INNER JOIN employee ON admin.Admin_ID = employee.Employee_ID WHERE Admin_ID='" + ssoNum + "' AND Password='" + generatedPass + "'");
if (result.next()){
request.getSession();
Expand All @@ -46,6 +46,10 @@ if (result.next()){
Cookie adminCookie2 = new Cookie("admin", Integer.toString(ssoNum));
adminCookie2.setPath("/");
response.addCookie(adminCookie2);
Cookie newCookie = new Cookie("name",result.getString("Name"));
newCookie.setMaxAge(30*60);
newCookie.setPath("/");
response.addCookie(newCookie);
if(result.getInt("Password_Flag") == 1){
stmt.close();
connection.close();
Expand Down
33 changes: 22 additions & 11 deletions WebContent/html/webpages/components/adminnavbar.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,48 @@
<ul class="nav navbar-nav navbar-right">
<li><a href="../../webpages/">Home</a></li>
<li id = "adminbar"></li>
<li><a href="../requestPage.jsp">Request Device</a></li>
<li><a href="../returnPage.jsp">My Devices</a></li>
<li><a href="../listingPage.jsp">Device Library</a></li>
<li><a href="../shoppingCart.jsp">Shopping Cart</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Device Library <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="../requestPage.jsp">Request Hub</a></li>
<li><a href="../listingPage.jsp">Full Inventory Listing</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">My Stuff <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="../returnPage.jsp">My Devices</a></li>
<li><a href="../shoppingCart.jsp">My Shopping Cart</a></li>
<li><a href="../profileSettings.jsp">Profile Settings</a></li>
</ul>
</li>
<li><a href="../logout.jsp">Logout</a></li>
</ul>
</div>
<%
Cookie[] usercookies = request.getCookies();
String navsso = "invalid";
String navname = "error";
User self = new User();
int admin = 0;
//iterate cookies
if(usercookies != null){
for(Cookie c : usercookies){
if(c.getName().equals("ssoNum") || c.getName().equals("admin")){//when (and if) we get to user cookie we want to reset it
navsso = c.getValue();
String cookiename = c.getName();
c.setMaxAge(30*60);//delete current
c.setPath("/");
response.addCookie(c);
}
if(c.getName().equals("admin")){
admin = 1;
}
if(c.getName().equals("name")){
navname = c.getValue();
c.setMaxAge(30*60);
c.setPath("/");
response.addCookie(c);
}
}
}
if(navsso.equals("invalid")){//if we didn't get a cookie, redirect to the homepage to log in again!
Expand All @@ -57,16 +72,12 @@
response.sendRedirect("../index.jsp");
return;
}
else{
self = EmployeeQueries.getEmployeeByID(Integer.parseInt(navsso));
navname = self.getName();
}
}
%>
</div>
<script>
var name = '<%=navname%>';
document.getElementById('user').innerHTML = "Hi " + name + "!";
if(<%=admin%> == 1)
document.getElementById('adminbar').innerHTML = '<a href="admin.jsp">Admin Hub</a>'
document.getElementById('adminbar').innerHTML = '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Admin Hub <span class="caret"></span></a><ul class="dropdown-menu"><li><a href="admin.jsp">Admin Hub Main</a></li><li><a href="adminApprove.jsp">Ticket Hub</a></li><li><a href="adminDeviceSettings.jsp">Device Hub</a></li><li><a href="adminLocation.jsp">Location Hub</a></li></ul>'
</script>
35 changes: 23 additions & 12 deletions WebContent/html/webpages/components/navbar.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,60 @@
<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 id = "adminbar"></li>
<li><a href="requestPage.jsp">Request Device</a></li>
<li><a href="returnPage.jsp">My Devices</a></li>
<li><a href="listingPage.jsp">Device Library</a></li>
<li><a href="shoppingCart.jsp">Shopping Cart</a></li>
<li class = "dropdown" id = "adminbar"></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Device Library <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="requestPage.jsp">Request Hub</a></li>
<li><a href="listingPage.jsp">Full Inventory Listing</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">My Stuff <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="returnPage.jsp">My Devices</a></li>
<li><a href="shoppingCart.jsp">My Shopping Cart</a></li>
<li><a href="profileSettings.jsp">Profile Settings</a></li>
</ul>
</li>
<li><a href="logout.jsp">Logout</a></li>
</ul>
</div>
<%
Cookie[] usercookies = request.getCookies();
String navsso = "invalid";
String navname = "error";
User self = new User();
int admin = 0;
//iterate cookies
if(usercookies != null){
for(Cookie c : usercookies){
if(c.getName().equals("ssoNum") || c.getName().equals("admin")){//when (and if) we get to user cookie we want to reset it
navsso = c.getValue();
String cookiename = c.getName();
c.setMaxAge(30*60);//delete current
c.setPath("/");
response.addCookie(c);
}
if(c.getName().equals("admin")){
admin = 1;
}
if(c.getName().equals("name")){
navname = c.getValue();
c.setMaxAge(30*60);
c.setPath("/");
response.addCookie(c);
}
}
}
if(navsso.equals("invalid")){//if we didn't get a cookie, redirect to the homepage to log in again!
response.sendRedirect("../../index.jsp");
return;
}
else{
self = EmployeeQueries.getEmployeeByID(Integer.parseInt(navsso));
navname = self.getName();
}
%>
</div>
<script>
var name = '<%=navname%>';
document.getElementById('user').innerHTML = "Hi " + name + "!";
if(<%=admin%> == 1)
document.getElementById('adminbar').innerHTML = '<a href="administration/admin.jsp">Admin Hub</a>'
document.getElementById('adminbar').innerHTML = '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Admin Hub <span class="caret"></span></a><ul class="dropdown-menu"><li><a href="administration/admin.jsp">Admin Hub Main</a></li><li><a href="administration/adminApprove.jsp">Ticket Hub</a></li><li><a href="administration/adminDeviceSettings.jsp">Device Hub</a></li><li><a href="administration/adminLocation.jsp">Location Hub</a></li></ul>'
</script>
8 changes: 6 additions & 2 deletions WebContent/html/webpages/profileSettings.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</div>

<!-- Profile Settings -->
<div class = "profileContainer" style="visibility: visible;">
<div class = "profileContainer">
<div style = "display: inline-block;">
<!-- Where profile image gets edited -->
<div class = "imageContainer">
Expand Down Expand Up @@ -123,7 +123,7 @@
</form>
</div>
<!-- Notification Settings -->
<div class = "notificationContainer">
<div class = "notificationContainer" style = "visibility: hidden;">
<!-- Where main user information is edited -->
<form action = "redirect/notificationSettingsRedirect.jsp" class = "infobar">
<h2>Email Notification Settings</h2>
Expand Down Expand Up @@ -153,6 +153,10 @@
</div>
</form>
</div>

<%
User self = EmployeeQueries.getEmployeeByID(Integer.parseInt(navsso));
%>
<script>
var iconSelect;
Expand Down
1 change: 1 addition & 0 deletions WebContent/html/webpages/redirect/orderFormHandler.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pageEncoding="ISO-8859-1"%>
</nav>
<script type="text/javascript">
<%
User self = EmployeeQueries.getEmployeeByID(Integer.parseInt(navsso));
// If location id is 0, it is a custom location which must be added to the database before employee preffered location can be updated
int location=-1;
if(Integer.parseInt(request.getParameter("location_dropdown"))==0)
Expand Down
10 changes: 8 additions & 2 deletions WebContent/html/webpages/returnComplete.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@
</nav>
</head>
<body>
<div style = "margin-left: 15px;">
<h2>Returning Devices</h2>
<p>Thanks for returning some devices!</p>
<p>You can ship the devices to the following address:</p>
<div style = "background-color: white; display: inline-block; padding: 10px; margin-bottom: 5px; border-radius: 5px;">
Synchrony Financial<br>777 Long Ridge Road<br>Stamford, CT<br>06902
</div>
<form action = "returnPage.jsp">
<button type = "submit" class = "btn btn-primary">Go Back</button>
</form>
</div>
<%
//get string from request form
String devices = request.getParameter("devicesToReturn");
DeviceQueries.returnDevices(devices);
//String devices = request.getParameter("devicesToReturn");
//DeviceQueries.returnDevices(devices);
%>
</body>
</html>
4 changes: 0 additions & 4 deletions WebContent/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@

<%
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){
Expand Down
9 changes: 6 additions & 3 deletions WebContent/userLogin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
pageEncoding="ISO-8859-1"%>
<%@ page import = "java.sql.*" %>
<%
int ssoNum;
Cookie userCookie;
Cookie userCookie,newCookie;
ssoNum = Integer.parseInt(request.getParameter("username"));
int ssoNum = Integer.parseInt(request.getParameter("username"));
Class.forName("com.mysql.jdbc.Driver");
String database = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317";
Expand All @@ -24,6 +23,10 @@ if (result.next()){
userCookie.setMaxAge(30*60);
userCookie.setPath("/");
response.addCookie(userCookie);
newCookie = new Cookie("name",result.getString("Name"));
newCookie.setMaxAge(30*60);
newCookie.setPath("/");
response.addCookie(newCookie);
stmt.close();
connection.close();
response.sendRedirect("html/webpages/index.jsp");
Expand Down