Interface EmailVerificationService

All Known Implementing Classes:
EmailVerificationServiceImpl

public interface EmailVerificationService
Service for managing email verification tokens
  • Method Details

    • createToken

      EmailVerificationTokenModel createToken(UserModel user, String tokenType, String newEmail, int expirationHours)
      Create a new verification token for a user
      Parameters:
      user - The user
      tokenType - The type of token (e.g., "ACCOUNT_VERIFICATION", "PASSWORD_RESET", "EMAIL_CHANGE")
      newEmail - The new email (for email change requests), null otherwise
      expirationHours - Token expiration time in hours
      Returns:
      The created token model
    • validateToken

      Optional<EmailVerificationTokenModel> validateToken(String token, String tokenType)
      Validate and retrieve a token
      Parameters:
      token - The token string
      tokenType - The expected token type
      Returns:
      Optional containing the token if valid
    • markTokenAsUsed

      void markTokenAsUsed(EmailVerificationTokenModel token)
      Mark a token as used
      Parameters:
      token - The token to mark as used
    • deleteExpiredTokens

      void deleteExpiredTokens()
      Delete expired tokens (cleanup task)
    • deleteUserTokensByType

      void deleteUserTokensByType(UserModel user, String tokenType)
      Delete all tokens for a user of a specific type
      Parameters:
      user - The user
      tokenType - The token type