Class EmailLoginService

java.lang.Object
org.localify.auth.login.EmailLoginService

@Service @Transactional public class EmailLoginService extends Object
Service for handling email-based login.
  • 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

      public UserEmailTokenLoginResponse sendEmailToken(String email)
      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

      public User login(UUID nonce, String code)
      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

      public User login(UUID nonce, String code, boolean verifyEmail)
      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

      public AuthCredentialsMergeable link(UUID userId, UUID nonce, String code, Boolean changeEmail)
      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.