Class AuthenticationController
java.lang.Object
com.ntu.fdae.group1.bto.controllers.user.AuthenticationController
Controller for authentication-related operations
-
Constructor Summary
ConstructorsConstructorDescriptionAuthenticationController
(IAuthenticationService authService) Constructs a new AuthenticationController -
Method Summary
Modifier and TypeMethodDescriptionboolean
changePassword
(User user, String newPassword) Changes a user's passwordAttempts to log in a userboolean
registerApplicant
(String nric, String name, int age, MaritalStatus maritalStatus) Registers a new applicant
-
Constructor Details
-
AuthenticationController
Constructs a new AuthenticationController- Parameters:
authService
- The authentication service to use
-
-
Method Details
-
login
Attempts to log in a user- Parameters:
nric
- User's NRICpassword
- User's password- Returns:
- The authenticated user if successful
- Throws:
AuthenticationException
- if authentication fails
-
changePassword
public boolean changePassword(User user, String newPassword) throws WeakPasswordException, DataAccessException Changes a user's password- Parameters:
user
- The user whose password to changenewPassword
- The new password- Returns:
- true if password change was successful, false otherwise
- Throws:
WeakPasswordException
- if the new password does not meet strength criteria.DataAccessException
- if there's an error saving the user data.
-
registerApplicant
public boolean registerApplicant(String nric, String name, int age, MaritalStatus maritalStatus) throws AuthenticationException, DataAccessException Registers a new applicant- Parameters:
nric
- NRIC of the new user (must be unique)name
- Full name of the userage
- Age of the usermaritalStatus
- Marital status of the user- Returns:
- true if registration was successful, false otherwise
- Throws:
AuthenticationException
- if NRIC already exists or validation fails.DataAccessException
- if saving fails.
-