* the password used for logging in
* @return true if the user exists with that password, false otherwise
*/
public CurrentUser loginUser(String username, String password) {
CurrentUser currentUser = null;
if(username.equals("Admin") && password.equals("masterPassword")){
currentUser = new CurrentUser();
currentUser.setLoggedIn(true);
currentUser.setAdmin(true);
currentUser.setUsername(username);
return currentUser;
}
else {
User tempUser = ofy().query(User.class).filter("username",
username).get();
if(tempUser != null ) {
currentUser = new CurrentUser();
currentUser.setLoggedIn(true);
currentUser.setUsername(username);
if(tempUser.isAdministrator())
currentUser.setAdmin(true);
else
currentUser.setAdmin(false);
return currentUser;
}
else
return null;
}