From 1a9f13581e0b9eb238bae51be1c4a7ef4826c1bd Mon Sep 17 00:00:00 2001 From: pbs2h21asc Date: Tue, 31 Jan 2023 12:27:14 +0100 Subject: [PATCH] Admin Controller bearbeitet --- .../AdminController.java | 78 ++++++++++++++----- .../createCoworker-view.fxml | 9 ++- 2 files changed, 63 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/AdminController.java b/src/main/java/com/bib/essensbestellungsverwaltung/AdminController.java index ef5200c..9bf624f 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/AdminController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/AdminController.java @@ -1,43 +1,81 @@ package com.bib.essensbestellungsverwaltung; +import javafx.fxml.FXML; +import javafx.scene.control.Alert; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; public class AdminController { - private TextField lastname; - private TextField firstname; - private TextField street; - private TextField number; - private TextField city; - private TextField plz; - private TextField email; - private PasswordField password; + @FXML + TextField lastname; + @FXML + TextField firstname; + @FXML + TextField street; + @FXML + TextField number; + @FXML + TextField city; + @FXML + TextField plz; + @FXML + TextField email; + @FXML + PasswordField password; + @FXML protected void onBtSignUp(){ - String ln = lastname.toString(); - String fn = firstname.toString(); - String st = street.toString(); - String nr = number.toString(); - String cityString = city.toString(); - String plzString = plz.toString(); - String emailString = email.toString(); - String pw = password.toString(); - String[] userData = new String[]{ln,fn,pw,emailString}; - String[] addressData = new String[]{st,nr,plzString,cityString}; - Address adresse = new Address(st,nr,plzString,cityString); - Worker worker = new Worker(ln,fn,pw,emailString,adresse); + String ln = lastname.getText(); + String fn = firstname.getText(); + String st = street.getText(); + String nr = number.getText(); + String cityString = city.getText(); + String plzString = plz.getText(); + String emailString = email.getText(); + String pw = password.getText(); + + + + if(!pw.matches("^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=])(?=\\S+$).{8,}$")){ + + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("Passwort"); + alert.setHeaderText("Ungültiges Passwort"); + alert.setContentText("Das Passwort benötigt mindestens: \n-8 Zeichen\n-einen Kleinbuchstaben\n-einen Großbuchstaben\n-ein Sonderzeichen\n-kein Leerzeichen"); + password.setText(""); + } + + if(!emailString.matches("^(?=.{1,64}@)[A-Za-z0-9_-]+(\\\\.[A-Za-z0-9_-]+)*@[^-][A-Za-z0-9-]+(\\\\.[A-Za-z0-9-]+)*(\\\\.[A-Za-z]{2,})$")){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("E-Mail"); + alert.setHeaderText("Ungültige E-Mail Adresse"); + alert.setContentText("Bitte geben sie eine gültige E-Mail Adresse an"); + email.setText(""); + } + + //String[] userData = new String[]{ln,fn,pw,emailString}; + //String[] addressData = new String[]{st,nr,plzString,cityString}; + + Address address = new Address(st,nr,plzString,cityString); + + Worker worker = new Worker(ln,fn,pw,emailString,address); AccountMgr.createWorker(worker); } + @FXML + protected void onBtCancel(){ + + } + } diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/createCoworker-view.fxml b/src/main/resources/com/bib/essensbestellungsverwaltung/createCoworker-view.fxml index 6d518a1..c815124 100644 --- a/src/main/resources/com/bib/essensbestellungsverwaltung/createCoworker-view.fxml +++ b/src/main/resources/com/bib/essensbestellungsverwaltung/createCoworker-view.fxml @@ -3,6 +3,7 @@ + @@ -141,16 +142,16 @@ - + - + -