moving currentUser to AccountMgr
moving to stable: Reshad Meher: login
This commit is contained in:
parent
3643f44afb
commit
d2df46eaa6
@ -17,6 +17,8 @@ import java.util.List;
|
||||
*/
|
||||
public class AccountMgr {
|
||||
|
||||
static User currentUser = null;
|
||||
|
||||
/**
|
||||
* creates a user with createUser(...) and adds its id to the 'worker' table
|
||||
* @param worker the worker to be created
|
||||
|
@ -7,7 +7,7 @@ import java.util.Scanner;
|
||||
* @author Malte Schulze Hobeling
|
||||
*/
|
||||
public class ConsoleMain {
|
||||
static User currentUser = null;
|
||||
//static User currentUser = null;
|
||||
static boolean running = true;
|
||||
public static void main(String[] args) {
|
||||
boolean firstRun = Database.init();
|
||||
@ -18,12 +18,12 @@ public class ConsoleMain {
|
||||
}
|
||||
AccountMgr.getPrice();
|
||||
while (running){
|
||||
if(currentUser == null){
|
||||
if(AccountMgr.currentUser == null){
|
||||
defaultMenu();
|
||||
}else{
|
||||
if(currentUser.getClass().getSimpleName().equals("Worker")){
|
||||
if(AccountMgr.currentUser.getClass().getSimpleName().equals("Worker")){
|
||||
adminMenu();
|
||||
}else if(currentUser.getClass().getSimpleName().equals("Parent")){
|
||||
}else if(AccountMgr.currentUser.getClass().getSimpleName().equals("Parent")){
|
||||
parentMenu();
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ public class ConsoleMain {
|
||||
switch (selection) {
|
||||
case "0" -> running = false;
|
||||
case "1" -> {
|
||||
currentUser = ConsoleLib.loginPrompt();
|
||||
AccountMgr.currentUser = ConsoleLib.loginPrompt();
|
||||
}
|
||||
case "2" -> ConsoleLib.showFood_planPrompt();
|
||||
case "3" -> ConsoleLib.createParentPrompt();
|
||||
@ -71,12 +71,12 @@ public class ConsoleMain {
|
||||
String selection = sc.nextLine();
|
||||
switch (selection) {
|
||||
case "0" -> {
|
||||
currentUser = null;
|
||||
AccountMgr.currentUser = null;
|
||||
}
|
||||
case "1" -> ConsoleLib.createWorkerPrompt();
|
||||
case "2" -> ConsoleLib.createParentPrompt();
|
||||
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUser.getId()));
|
||||
case "4" -> ConsoleLib.matchParentChildPrompt(String.valueOf(currentUser.getId()));
|
||||
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(AccountMgr.currentUser.getId()));
|
||||
case "4" -> ConsoleLib.matchParentChildPrompt(String.valueOf(AccountMgr.currentUser.getId()));
|
||||
case "5" -> ConsoleLib.createFoodPrompt();
|
||||
case "6" -> ConsoleLib.createFood_planPrompt();
|
||||
case "7" -> ConsoleLib.showFood_planPrompt();
|
||||
@ -102,9 +102,9 @@ public class ConsoleMain {
|
||||
String selection = sc.nextLine();
|
||||
switch (selection) {
|
||||
case "0" -> {
|
||||
currentUser = null;
|
||||
AccountMgr.currentUser = null;
|
||||
}
|
||||
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUser.getId()));
|
||||
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(AccountMgr.currentUser.getId()));
|
||||
case "6" -> ConsoleLib.tablePrompt();
|
||||
case "7" -> ConsoleLib.showFood_planPrompt();
|
||||
case "8" -> ConsoleLib.createFood_selectionPrompt();
|
||||
|
@ -19,15 +19,19 @@ public class LoginController {
|
||||
@FXML
|
||||
private PasswordField pfPassword;
|
||||
|
||||
HashMap<String,String> benutzerMap = new HashMap<String,String>();
|
||||
@FXML
|
||||
protected void onBtLoginClick() throws IOException {
|
||||
benutzerMap.put("Reshad","1234");
|
||||
String email = tfEmail.getText();
|
||||
String password = pfPassword.getText();
|
||||
if(benutzerMap.containsKey(email) && benutzerMap.containsValue(password)){
|
||||
// if user is worker: StartViewApplication.changeScene("workerMenu-view.fxml");
|
||||
long loginPruefen = AccountMgr.login(email,password);
|
||||
if(loginPruefen > 0){
|
||||
AccountMgr.currentUser = AccountMgr.getUserById(loginPruefen);
|
||||
if(AccountMgr.currentUser.getClass().getSimpleName().equals("Worker")){
|
||||
StartViewApplication.changeScene("workerMenu-view.fxml");
|
||||
}else{
|
||||
StartViewApplication.changeScene("parentMenu-view.fxml");
|
||||
}
|
||||
|
||||
}else {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR,"Email oder Passwort ist falsch");
|
||||
alert.showAndWait();
|
||||
|
Loading…
Reference in New Issue
Block a user