Class AuthenticationService

java.lang.Object
edu.ntnu.idatt2106_2023_06.backend.service.security.AuthenticationService
All Implemented Interfaces:
IAuthenticationService

@Service public class AuthenticationService extends Object implements IAuthenticationService
  • 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:
      register in interface IAuthenticationService
      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

      public AuthenticationResponseDTO authenticate(UserLoginDTO request)
      Authenticates a user with the given credentials.
      Specified by:
      authenticate in interface IAuthenticationService
      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.