Class UserAuthServiceImpl
java.lang.Object
it.univr.passportease.service.user.impl.UserAuthServiceImpl
- All Implemented Interfaces:
UserAuthService
Implementation of
UserAuthService
, which provides methods for user authentication.-
Field Summary
Modifier and TypeFieldDescriptionprivate org.springframework.security.authentication.AuthenticationManager
The service that handles the authentication.private final CitizenRepository
The repository forCitizen
entity.private final JwtService
The service that handles the JWT.private final MapUser
The service that maps theUser
entity to theLoginOutput
DTO.private org.springframework.security.crypto.password.PasswordEncoder
The service that encodes the password.private final UserRepository
The repository forUser
entity. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionLogs in the user.register
(RegisterInput registerInput) Registers the user.
-
Field Details
-
userRepository
The repository forUser
entity. -
citizenRepository
The repository forCitizen
entity. -
mapUser
The service that maps theUser
entity to theLoginOutput
DTO. -
jwtService
The service that handles the JWT. -
passwordEncoder
private org.springframework.security.crypto.password.PasswordEncoder passwordEncoderThe service that encodes the password. -
authenticationManager
private org.springframework.security.authentication.AuthenticationManager authenticationManagerThe service that handles the authentication.
-
-
Constructor Details
-
UserAuthServiceImpl
public UserAuthServiceImpl()
-
-
Method Details
-
login
public LoginOutput login(String fiscalCode, String password) throws UserNotFoundException, WrongPasswordException Logs in the user.- Specified by:
login
in interfaceUserAuthService
- Parameters:
fiscalCode
- user fiscal codepassword
- user password- Returns:
LoginOutput
object containing the access token and the refresh token- Throws:
UserNotFoundException
- if the user is not foundWrongPasswordException
- if the password is wrong
-
register
public LoginOutput register(RegisterInput registerInput) throws UserNotFoundException, UserAlreadyExistsException Registers the user.- Specified by:
register
in interfaceUserAuthService
- Parameters:
registerInput
-RegisterInput
object containing the user data- Returns:
LoginOutput
object containing the access token and the refresh token- Throws:
UserNotFoundException
- if the user is not foundUserAlreadyExistsException
- if the user already exists
-