Class AuthenticationService
java.lang.Object
edu.ntnu.idatt2106_2023_06.backend.service.security.AuthenticationService
- All Implemented Interfaces:
IAuthenticationService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(UserLoginDTO request) Authenticates a user with the given credentials.register(UserRegisterDTO userRegisterDTO) Registers a user to the system.
-
Constructor Details
-
AuthenticationService
public AuthenticationService()
-
-
Method Details
-
register
@Transactional public AuthenticationResponseDTO register(UserRegisterDTO userRegisterDTO) throws jakarta.mail.MessagingException Registers a user to the system.- Specified by:
registerin interfaceIAuthenticationService- Parameters:
userRegisterDTO- the information of the user to be registered.- Returns:
- an AuthenticationResponse containing the JWT token of the user.
- Throws:
jakarta.mail.MessagingException
-
authenticate
Authenticates a user with the given credentials.- Specified by:
authenticatein interfaceIAuthenticationService- Parameters:
request- the authentication request containing the username and password of the user.- Returns:
- an AuthenticationResponse containing the JWT token of the authenticated user.
- Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException- if the username of the user is not found in the database.
-