java.lang.Object
ai.tutor.cab302exceptionalhandlers.controller.AuthController
ai.tutor.cab302exceptionalhandlers.controller.LoginController

public class LoginController extends AuthController
Controls the login screen for creating new user accounts in the AI tutor application.

Extends AuthController to inherit common authentication logic and UI handling. Manages the login form, validates user input (username, password), and access existing users in the database via UserDAO.

See Also:
  • Constructor Details

  • Method Details

    • onFieldChanged

      protected void onFieldChanged(javafx.scene.input.KeyEvent e)
      Handles key events in the login form’s text fields to track input changes.

      Updates boolean flags (usernameEmpty and passwordEmpty based on whether the username or password fields are empty. Calls submitButtonToggle() to enable or disable the submit button accordingly.

      Specified by:
      onFieldChanged in class AuthController
      Parameters:
      e - The key event triggered by typing in a text field
    • submitButtonToggle

      protected void submitButtonToggle()
      Enables or disables the submit button based on input field states.

      Disables the button if any of usernameEmpty or passwordEmpty is true, ensuring all fields are filled before submission.

      Specified by:
      submitButtonToggle in class AuthController
    • onSubmit

      protected void onSubmit()
      Processes the sign-up form submission to create a new user account.

      Retrieves the username, password, and confirm password from the form fields. Validates that the passwords match, authenticates the user via authenticateUser(String, String), and navigates to the chat screen if successful. Displays error feedback for invalid inputs or mismatches.

      Specified by:
      onSubmit in class AuthController
    • authenticateUser

      public User authenticateUser(String username, String password) throws IllegalArgumentException, SecurityException, SQLException
      Authenticates an existing user with the provided username and password.

      Checks for an existing username, and verifies the password hashUser.verifyPassword(String) via UserDAO.getUser(String), and creates the user in the database if valid.

      Specified by:
      authenticateUser in class AuthController
      Parameters:
      username - The username for the existing user
      password - The password to be verified against the hashed password
      Returns:
      The existing User object
      Throws:
      IllegalArgumentException - If the username does not exist
      SecurityException - if the password is incorrect to the hash verification
      SQLException - If database operations fail