Package org.localify.auth.login
Class EmailLoginService
java.lang.Object
org.localify.auth.login.EmailLoginService
Service for handling email-based login.
-
Constructor Summary
ConstructorsConstructorDescriptionEmailLoginService(org.springframework.mail.javamail.JavaMailSender emailSender, UserEmailAuthTokenRepository userEmailAuthTokenRepository, ServletUtils servletUtils, UserRepository userRepository, UserService userService, JwtService jwtService, AccountMergingService accountMergingService) Constructs a new EmailLoginService. -
Method Summary
Modifier and TypeMethodDescriptionLinks an email account to an existing user account.Logs in a user with the given nonce and code.Logs in a user with the given nonce and code, and optionally verifies the email.sendEmailToken(String email) Sends an email token to the specified email address.
-
Constructor Details
-
EmailLoginService
@Autowired public EmailLoginService(org.springframework.mail.javamail.JavaMailSender emailSender, UserEmailAuthTokenRepository userEmailAuthTokenRepository, ServletUtils servletUtils, UserRepository userRepository, UserService userService, JwtService jwtService, AccountMergingService accountMergingService) Constructs a new EmailLoginService.- Parameters:
emailSender- The email sender.userEmailAuthTokenRepository- The repository for user email auth tokens.servletUtils- The servlet utilities.userRepository- The user repository.userService- The user service.jwtService- The JWT service.accountMergingService- The account merging service.
-
-
Method Details
-
sendEmailToken
Sends an email token to the specified email address. If a user with the email does not exist, a new one is created.- Parameters:
email- The email address to send the token to.- Returns:
- A response containing the nonce for the login attempt.
-
login
Logs in a user with the given nonce and code.- Parameters:
nonce- The nonce from the initial email token request.code- The code sent to the user's email.- Returns:
- The authenticated user.
-
login
Logs in a user with the given nonce and code, and optionally verifies the email.- Parameters:
nonce- The nonce from the initial email token request.code- The code sent to the user's email.verifyEmail- Whether to mark the user's email as verified.- Returns:
- The authenticated user.
-
link
Links an email account to an existing user account.- Parameters:
userId- The ID of the user to link the account to.nonce- The nonce from the email login attempt.code- The code from the email.changeEmail- Whether to change the email of the existing account.- Returns:
- An object containing either the new auth credentials or the mergeable account details.
-