Added login for estate agents

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
2017-04-19 10:05:37 +02:00
parent ce1e8e3397
commit b682ec0e43

View File

@ -51,7 +51,12 @@ public class Main {
} }
break; break;
case MENU_ESTATES: case MENU_ESTATES:
showEstateMenu(); if (loginEstateAgent()) {
showEstateMenu();
}
else {
System.out.println("The username or password was wrong.");
}
break; break;
case QUIT: case QUIT:
return; return;
@ -69,6 +74,19 @@ public class Main {
return sudoPassword.equals(passwordInput); return sudoPassword.equals(passwordInput);
} }
/**
* Performs a login for an estate agent.
*
* @return true if the login is successful, false otherwise
*/
private static boolean loginEstateAgent() {
System.out.println("Please insert the username and password of a valid estate agent.");
String username = FormUtil.readString("Username");
String passwordInput = FormUtil.readPassword();
EstateAgent agent = _orm.get(username);
return agent != null && agent.getPassword().equals(passwordInput);
}
/** /**
* TODO Shows the estate management. * TODO Shows the estate management.
*/ */