diff --git a/WebContent/adminLogin.jsp b/WebContent/adminLogin.jsp index 54d078e..95e1db4 100644 --- a/WebContent/adminLogin.jsp +++ b/WebContent/adminLogin.jsp @@ -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(); @@ -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(); diff --git a/WebContent/html/webpages/components/adminnavbar.jsp b/WebContent/html/webpages/components/adminnavbar.jsp index 12663db..160a20a 100644 --- a/WebContent/html/webpages/components/adminnavbar.jsp +++ b/WebContent/html/webpages/components/adminnavbar.jsp @@ -19,10 +19,21 @@
@@ -30,7 +41,6 @@ Cookie[] usercookies = request.getCookies(); String navsso = "invalid"; String navname = "error"; - User self = new User(); int admin = 0; //iterate cookies @@ -38,7 +48,6 @@ 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); @@ -46,6 +55,12 @@ 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! @@ -57,10 +72,6 @@ response.sendRedirect("../index.jsp"); return; } - else{ - self = EmployeeQueries.getEmployeeByID(Integer.parseInt(navsso)); - navname = self.getName(); - } } %> @@ -68,5 +79,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/components/navbar.jsp b/WebContent/html/webpages/components/navbar.jsp index 70e6caa..0f32c01 100644 --- a/WebContent/html/webpages/components/navbar.jsp +++ b/WebContent/html/webpages/components/navbar.jsp @@ -18,11 +18,22 @@ @@ -30,7 +41,6 @@ Cookie[] usercookies = request.getCookies(); String navsso = "invalid"; String navname = "error"; - User self = new User(); int admin = 0; //iterate cookies @@ -38,7 +48,6 @@ 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); @@ -46,21 +55,23 @@ 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(); - } %> \ No newline at end of file diff --git a/WebContent/html/webpages/profileSettings.jsp b/WebContent/html/webpages/profileSettings.jsp index 71cd20b..ce0f0b7 100644 --- a/WebContent/html/webpages/profileSettings.jsp +++ b/WebContent/html/webpages/profileSettings.jsp @@ -86,7 +86,7 @@ -