package database_comm;
import java.sql.*;

public class UserDatabase
{
	//Debug user class for SQL connection
	//TODO remove
	public static class User
	{
		public String username;
		public String passwordHash;
		public String firstName;
		public String lastName;

		public String toString()
		{
			return username + ", " + passwordHash + ", " + firstName + " " + lastName;
		}
	}
	
	public static User getUserFromLogin(String username, String passwordHash)
	{

		//Create and execute query to find item with matching barcode
		DatabaseConnection connection = new DatabaseConnection();
		String query = "SELECT * FROM USERS WHERE USERNAME = '" + username + "' AND PASS_HASH = '" +  passwordHash + "'";
		ResultSet rs = connection.executeQuery(query);

		try
		{
			//Check if our query got any results
			if (rs.next())
			{
				//If so, return item with variables assigned
				User returnUser = new User();
				returnUser.username = rs.getString("USERNAME");
				returnUser.passwordHash = rs.getString("PASS_HASH");
				returnUser.firstName = rs.getString("FIRST");
				returnUser.lastName = rs.getString("LAST");
				return returnUser;
			}
			else
			{
				//If not, return null
				System.out.println("User with the given credentials not found");
				return null;
			}			
		}
		catch (SQLException e)
		{
			e.printStackTrace();
			return null;
		}
	}


}

@@ -255,16 +255,42 @@
 astName;
+%0A%09%09public boolean isAdmin;
 %0A%0A%09%09publ
@@ -386,24 +386,59 @@
 %22 + lastName
+ + (isAdmin ? %22, admin%22 : %22, user%22)
 ;%0A%09%09%7D%0A%09%7D%0A%09%0A%09
@@ -1164,24 +1164,76 @@
 ng(%22LAST%22);%0A
+%09%09%09%09returnUser.isAdmin = rs.getBoolean(%22IS_ADMIN%22);%0A
 %09%09%09%09return r

Add isAdmin trait to user