Skip to content
Snippets Groups Projects
Commit dff985c1 authored by Fiza Baloch (fwb426)'s avatar Fiza Baloch (fwb426)
Browse files

resolve issue where isManager was returning incorrect result.

parent 23091d58
No related branches found
No related tags found
7 merge requests!20Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!19Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!18Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!17Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!16Update QueueingApp/src/main/webapp/workerAddsCustomer.jsp,...,!14Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!13all updates to MAIN
......@@ -90,6 +90,7 @@ public class WorkerDAO extends DAO{
}
public boolean isManager(String username) throws SQLException{
System.out.println("RUNNING THE METHOD");
boolean userIsManager = false;
......@@ -102,20 +103,28 @@ public class WorkerDAO extends DAO{
}
Connection connection = createConnection();
System.out.println("Created connection");
// perform query
Statement statement = connection.createStatement();
String find_worker = "SELECT password FROM workers WHERE username = '" + username + "'";
String find_worker = "SELECT isManager FROM workers WHERE username = '" + username + "'";
PreparedStatement prepared_statement = connection.prepareStatement(find_worker);
ResultSet result = prepared_statement.executeQuery(find_worker);
System.out.println("Performed query");
// obtain query result
String manager = null;
if (result.next()) { manager = result.getString(1); }
// System.out.println(manager);
if (manager.equals("yes")) {
System.out.println("is managerrr");
}
// a user exists if there's a matching username and password in the database. if the password is null, the user doesn't exist.
if (manager != null && manager.equals("yes")) {
System.out.println("Determined manager");
userIsManager = true;
}
} catch (SQLException e) {
......
......@@ -59,11 +59,13 @@ public class loginServlet extends HttpServlet {
if(manager) {
session.setAttribute("isManager", true);
next_page = "workerView.jsp";
} else {
session.setAttribute("isManager", false);
next_page = "workerViewRegular.jsp";
}
next_page = "workerView.jsp";
// next_page = "workerView.jsp";
}
} catch (SQLException e) {
e.printStackTrace();
......
......@@ -286,7 +286,7 @@ body strong{
text-align: center;
position: relative;
top: 210px;
top: 310px;
}
.delete-customer-container {
......
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="appQueue.CustomerQueue" %>
<%@ page import="appQueue.Customer" %>
<!DOCTYPE html>
<!-- other info
- this webpage is super long -->
<html>
<head>
<meta charset="ISO-8859-1">
<title>Worker view</title>
<link rel="stylesheet" href="style.css">
<!-- Fonts-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,400;0,500;0,600;0,700;0,900;1,400&display=swap" rel="stylesheet">
</head>
<body>
<%
//checks first if the loggedin user is a manager
if(session.getAttribute("user") == null ){
response.sendRedirect("workerLogin.jsp");
}
%>
<div class="NavBar">
<strong> QueueApp </strong>
<ul class="nav_choice">
<a href="workerLogin.jsp">Login</a> <!-- This will bring us to the workerLogin.jsp, so the "href=login" will call the servlet to handle this req -->
<a href="landingPgServlet">Home</a>
</ul>
</div>
<div class="left-side-panel">
<div class="left-side-panel-top">
<div class="userBttn">
<button style="margin-top: 45px;" onclick="window.location.href='landingPgServlet'" >Home</button><br><br>
</div>
</div>
<div class="left-side-panel-bottom">
<div class="userBttn">
<button onclick="window.location.href='logoutServlet'">LogOut</button>
</div>
</div>
</div>
<div class="main-content">
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone Number</th>
<th>Queue position</th>
</tr>
</thead>
<tbody>
<% CustomerQueue.updateQueue(); %>
<% Customer[] customers = CustomerQueue.getCustomerList(); %>
<% if (customers.length > 0) { %>
<% for (int idx = 0; idx < customers.length; idx ++) { %>
<tr>
<td><%= customers[idx].getName() %></td>
<td><%= customers[idx].getEmail() %></td>
<td><%= customers[idx].getPhoneNumber() %></td>
<td><%= customers[idx].getQueuePosition() %></td>
</tr>
<% } %>
<% } %>
</tbody>
</table>
<div class="delete-customer-container">
<h1 style="padding-bottom: 25px; padding-top: 25px; font-size: 25px;">Remove a customer</h1>
<form method="post" action="deleteCustomerServlet">
<label for="customerEmail" style="padding: 70px 0;">Email: </label><br>
<input id="email" name="email_delete" cols="18"> <br>
<div class="userBttn" style="line-height: 95px;">
<button onclick="window.location.href='deleteCustomerServlet'">Delete customer</button>
</div>
</form>
</div>
</div>
<div class="footer-buttons">
<div class="userBttnBorder">
<button onclick="window.location.href='dischargeCustomerServlet'">Discharge customer</button><br><br>
<button onclick="window.location.href='customerServlet'">Add</button>
</div>
</div>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment