Interface PhoneVerificationRepository

All Known Implementing Classes:
JdbcPhoneVerificationRepository

public interface PhoneVerificationRepository
Port that stores the pending phone verification of each user, with the code hashed. An implementation never returns null.
  • Method Details

    • save

      void save(PhoneVerification verification)
      Stores the pending verification of a user, replacing the one it had.
      Parameters:
      verification - the verification.
    • findByUserId

      Optional<PhoneVerification> findByUserId(UUID userId)
      Finds the pending verification of a user.
      Parameters:
      userId - identifier of the user.
      Returns:
      the verification, or empty when there is none.
    • incrementAttempts

      int incrementAttempts(UUID userId)
      Counts a wrong submission, in one atomic step.
      Parameters:
      userId - identifier of the user.
      Returns:
      the number of attempts after the increment, or 0 when there is no pending verification.
    • deleteByUserId

      void deleteByUserId(UUID userId)
      Removes the pending verification of a user.
      Parameters:
      userId - identifier of the user.
    • deleteExpired

      int deleteExpired(Instant now)
      Deletes every pending verification that has expired.
      Parameters:
      now - current instant.
      Returns:
      the number of deleted verifications.