Package backend.logic
Klasse UserService
java.lang.Object
backend.logic.UserService
Service class for managing user-related operations including authentication,
retrieval, and modification of user data. Handles database interactions for
user management and provides session management through authentication.
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic User
authenticate
(String email, String password) Authenticates a user with the provided email and password.Retrieves all users from the database.Retrieves all user email addresses from the database.static User
getUserByEmail
(String email) Retrieves a complete user object by email address.static User
getUserById
(int userId) Retrieves a user by his unique ID.static int
getUserIdByEmail
(String email) Retrieves a user's ID by their email address.void
insertUser
(User newUser) Creates a new user in the database.static void
setConnectionProvider
(ConnectionProvider provider) secures DatabaseConnectionvoid
updateUser
(User editedUser) Updates an existing user's information in the database.
-
Konstruktordetails
-
UserService
public UserService()
-
-
Methodendetails
-
setConnectionProvider
secures DatabaseConnection -
authenticate
Authenticates a user with the provided email and password.- Parameter:
email
- The user's email addresspassword
- The user's password (plaintext)- Gibt zurück:
- The authenticated User object
- Löst aus:
AuthenticationException
- If authentication fails due to invalid credentials, account status, or database errorsIllegalStateException
- If the connection provider is not set
-
getAllUsers
Retrieves all users from the database.- Gibt zurück:
- List of all User objects in the system
- Löst aus:
IllegalStateException
- If the connection provider is not set
-
getUserById
Retrieves a user by his unique ID.- Parameter:
userId
- The ID of the user to retrieve- Gibt zurück:
- User object with the specified ID, or empty User object if not found
-
updateUser
Updates an existing user's information in the database.- Parameter:
editedUser
- The User object containing updated information- Löst aus:
IllegalStateException
- If the connection provider is not set
-
insertUser
Creates a new user in the database.- Parameter:
newUser
- The User object to be created- Löst aus:
IllegalStateException
- If the connection provider is not set
-
getAllUsersEmail
Retrieves all user email addresses from the database.- Gibt zurück:
- List of all email addresses in the system
-
getUserIdByEmail
Retrieves a user's ID by their email address.- Parameter:
email
- The email address to search for- Gibt zurück:
- The user ID if found, or -1 if not found
-
getUserByEmail
Retrieves a complete user object by email address.- Parameter:
email
- The email address to search for- Gibt zurück:
- User object if found, or null if not found
- Löst aus:
IllegalStateException
- If the connection provider is not set
-