diff --git a/src/main/java/edu/group5/app/control/LoginController.java b/src/main/java/edu/group5/app/control/LoginController.java index 2a860c9..59a1785 100644 --- a/src/main/java/edu/group5/app/control/LoginController.java +++ b/src/main/java/edu/group5/app/control/LoginController.java @@ -5,6 +5,9 @@ import edu.group5.app.model.user.UserService; import edu.group5.app.view.loginpage.LoginPageView; import edu.group5.app.view.loginpage.SignInPageView; +import javafx.scene.control.Alert; +import javafx.scene.control.Button; +import javafx.scene.control.ButtonType; import java.util.Arrays; @@ -38,17 +41,30 @@ public void handleSignIn(SignInPageView view, String firstName, String lastName, passwordChars[0] = '0'; } - boolean success = userService.registerUser( - "Customer", firstName, lastName, email, hashedPassword); + Alert privacyPolicy = new Alert(Alert.AlertType.CONFIRMATION); + privacyPolicy.setTitle("Accept Privacy Policy"); + privacyPolicy.setHeaderText("Accept Privacy Policy"); + privacyPolicy.setContentText( + "Your user information like:\n" + + "Name and email—as well as donations tied to your account—will be saved locally on your machine.\n" + + "By creating an account, you accept the right of our app to store this information."); - if (success) { - User user = userService.getUserByEmail(email); + if (privacyPolicy.showAndWait().orElse(ButtonType.CANCEL) == ButtonType.OK) { + boolean success = userService.registerUser( + "Customer", firstName, lastName, email, hashedPassword); - appState.setCurrentUser(user); - nav.showHomePage(); + if (success) { + User user = userService.getUserByEmail(email); + + appState.setCurrentUser(user); + nav.showHomePage(); + } else { + view.showError("Registration failed. Email may already be in use."); + } } else { - view.showError("Registration failed. Email may already be in use."); + view.showError("Registration failed. Must Accept Privacy Policy to create account."); } + } public void handleLogin(LoginPageView view, String email, char[] passwordChars) {