Skip to content

Commit

Permalink
feat[LoginController]: add dialog box for accepting privacy policy wh…
Browse files Browse the repository at this point in the history
…en signing up
  • Loading branch information
Lucy Ciara Herud-Thomassen authored and Lucy Ciara Herud-Thomassen committed Apr 14, 2026
1 parent d792af2 commit d6c8d3b
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/main/java/edu/group5/app/control/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit d6c8d3b

Please sign in to comment.