Class UserActivationListener

java.lang.Object
com.app.listener.UserActivationListener

@Component public class UserActivationListener extends Object
Listener class responsible for handling user activation events.

This class listens for user activation events and triggers the sending of an activation email to the user. The listener generates a unique verification token, saves it, and sends the email to the user with the token.

  • Constructor Details

    • UserActivationListener

      public UserActivationListener()
  • Method Details

    • sendActivationEmail

      @Async @EventListener @TransactionalEventListener(phase=AFTER_COMMIT) @Transactional(propagation=REQUIRES_NEW) public void sendActivationEmail(UserActivationDto userActivationDto)
      Listens to the user activation event and sends an activation email with a unique token to the user.

      This method is executed asynchronously and ensures the activation email is only sent after the transaction has been successfully committed. It generates a verification token, stores it in the database, and sends an email with the token to the user.

      Parameters:
      userActivationDto - the data transfer object containing the user information for activation
      Throws:
      IllegalArgumentException - if the user is not found in the repository