java.lang.Object
no.ntnu.principes.util.Auth
Manages authentication state throughout the application using the singleton pattern.
Stores the currently authenticated profile and provides access to authentication status.
-
Property Summary
Properties -
Constructor Summary
ConstructorsConstructorDescriptionAuth()Creates a new Auth instance with the member repository from the database manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticate(Long profileId) Authenticates a user with the specified profile ID.voidauthenticate(Profile profile) Authenticates a user with the specified profile.voidLogs out the current user by clearing profile data and authentication state.static AuthGets the singleton instance of Auth, creating it if necessary.Gets the currently authenticated profile.booleanChecks if a user is currently authenticated.javafx.beans.property.BooleanPropertyGets the observable authentication state property.javafx.beans.property.ObjectProperty<Profile> Gets the observable profile property.
-
Property Details
-
profile
Gets the observable profile property.- See Also:
-
-
Constructor Details
-
Auth
public Auth()Creates a new Auth instance with the member repository from the database manager.
-
-
Method Details
-
getInstance
Gets the singleton instance of Auth, creating it if necessary.- Returns:
- The single Auth instance for the application
-
authenticate
Authenticates a user with the specified profile.- Parameters:
profile- The profile to authenticate with
-
authenticate
Authenticates a user with the specified profile ID.- Parameters:
profileId- The ID of the profile to authenticate with- Throws:
IllegalArgumentException- If no profile exists with the given ID
-
deauthenticate
public void deauthenticate()Logs out the current user by clearing profile data and authentication state. -
isAuthenticatedProperty
public javafx.beans.property.BooleanProperty isAuthenticatedProperty()Gets the observable authentication state property.- Returns:
- Property indicating whether a user is authenticated
-
isAuthenticated
public boolean isAuthenticated()Checks if a user is currently authenticated.- Returns:
- True if a user is authenticated, false otherwise
-
profileProperty
Gets the observable profile property.- Returns:
- Property containing the currently authenticated profile
- See Also:
-
getProfile
Gets the currently authenticated profile.- Returns:
- The authenticated profile or null if no user is authenticated
-