Merge remote-tracking branch 'origin/main'
# Conflicts: # target/classes/com/example/vpr_javafx/HelloController.class
This commit is contained in:
commit
7b0ba5aee6
@ -1,6 +1,10 @@
|
||||
package com.example.vpr_javafx;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
@ -9,6 +13,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Matcher;
|
||||
@ -22,6 +27,10 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class Data {
|
||||
private String pathRead;
|
||||
@FXML
|
||||
private TextField tfPhone;
|
||||
@FXML
|
||||
private PasswordField pfPassword;
|
||||
|
||||
public Data(String pathRead) {
|
||||
this.pathRead = pathRead;
|
||||
@ -255,13 +264,19 @@ public class Data {
|
||||
* @return boolean inputValid
|
||||
* @author Kevin Maier
|
||||
*/
|
||||
public boolean validateData(String password, String phoneNumber)
|
||||
public boolean validateData(TextField tfPhone, PasswordField pfPassword)
|
||||
{
|
||||
boolean phoneNumberMatchFound;
|
||||
boolean passwordMatchFound;
|
||||
boolean phoneNumberValid = false;
|
||||
boolean passwordValid = false;
|
||||
|
||||
LoginDatei file = new LoginDatei("user.txt");
|
||||
HashMap<String, String> users = file.readFile();
|
||||
|
||||
String phoneNumber = tfPhone.getText();
|
||||
String password = pfPassword.getText();
|
||||
|
||||
Pattern phoneNumberPattern = Pattern.compile("[0-9]*");
|
||||
Pattern passwordPattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$");
|
||||
|
||||
@ -279,7 +294,7 @@ public class Data {
|
||||
phoneNumberMatchFound = phoneNumberMatcher.find();
|
||||
passwordMatchFound = passwordMatcher.find();
|
||||
|
||||
if (!phoneNumberMatchFound || phoneNumber.length() >= 15)
|
||||
if (!users.containsKey(phoneNumber) || !phoneNumberMatchFound || phoneNumber.length() >= 15)
|
||||
{
|
||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||
alert.setContentText("Login fehlgeschlagen. Die eingegebene Handynummer ist nicht valide.");
|
||||
@ -291,7 +306,7 @@ public class Data {
|
||||
phoneNumberValid = true;
|
||||
}
|
||||
|
||||
if (!passwordMatchFound || password.length() <8)
|
||||
if (!users.get(phoneNumber).equals(password) || !passwordMatchFound || password.length() <8)
|
||||
{
|
||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||
alert.setContentText("Login fehlgeschlagen. Das eingegebene Passwort ist nicht valide.");
|
||||
|
@ -86,11 +86,13 @@ public class HelloController {
|
||||
private TextField tfPhone;
|
||||
@FXML
|
||||
private PasswordField pfPassword;
|
||||
@FXML
|
||||
private Label allergene;
|
||||
|
||||
private Stage stage;
|
||||
private Scene scene;
|
||||
@FXML
|
||||
private Label allergene;
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private String veggieImageUrl = "pics/vegetarisch.png";
|
||||
@ -104,22 +106,8 @@ public class HelloController {
|
||||
@FXML
|
||||
protected void OnSignInButton(ActionEvent event) throws IOException
|
||||
{
|
||||
LoginDatei file = new LoginDatei("user.txt");
|
||||
HashMap<String, String> users = file.readFile();
|
||||
|
||||
String phoneNumber = tfPhone.getText();
|
||||
String password = pfPassword.getText();
|
||||
|
||||
Data data = new Data("user.txt");
|
||||
boolean inputValid = data.validateData(password, phoneNumber);
|
||||
|
||||
if (users.containsKey(phoneNumber) && inputValid)
|
||||
{
|
||||
if (users.get(phoneNumber).equals(password))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
data.validateData(tfPhone, pfPassword);
|
||||
}
|
||||
|
||||
|
||||
|
Binary file not shown.
4
user.txt
4
user.txt
@ -1,2 +1,2 @@
|
||||
Felix Düsterhaus;Sabine Gubitz;Detmolderstrasse 101,33102 Paderborn;1234567;Lisa,Peter;12345
|
||||
Kevin Pfannenstiel;Marlene Pfannenstiel;Fürstenallee 30, 33102 Paderborn;7654321;Anton;12345
|
||||
Felix Düsterhaus;Sabine Gubitz;Detmolderstrasse 101,33102 Paderborn;1234567;Lisa,Peter;12345678A
|
||||
Kevin Pfannenstiel;Marlene Pfannenstiel;Fürstenallee 30, 33102 Paderborn;7654321;Anton;12345678B
|
||||
|
Loading…
Reference in New Issue
Block a user