Class JdbcPhoneVerificationRepository
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.sms.JdbcPhoneVerificationRepository
- All Implemented Interfaces:
PhoneVerificationRepository
@Repository
public class JdbcPhoneVerificationRepository
extends Object
implements PhoneVerificationRepository
PhoneVerificationRepository over the pending_* columns of the user_phones table. It opens
no transaction: clearing a verification and then deleting an empty row runs in the caller's.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringStatement clearing every expired pending verification.private static final StringStatement clearing the pending columns of a user.private static final StringStatement deleting the rows that hold nothing at all.private static final StringStatement deleting the row of a user that holds neither a verified phone nor a pending verification.private static final StringQuery returning the pending verification of a user.private static final StringStatement counting a failed attempt atomically and returning the new count.private final org.springframework.jdbc.core.simple.JdbcClientJDBC client used to run the statements.private final PhoneVerificationRowMapperMaps a row to a verification.private static final StringStatement storing the pending verification of a user, creating the row if needed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteByUserId(UUID userId) intdeleteExpired(Instant now) findByUserId(UUID userId) intincrementAttempts(UUID userId) voidsave(PhoneVerification verification)
-
Field Details
-
UPSERT
Statement storing the pending verification of a user, creating the row if needed.- See Also:
-
FIND_BY_USER
Query returning the pending verification of a user.- See Also:
-
INCREMENT_ATTEMPTS
Statement counting a failed attempt atomically and returning the new count.- See Also:
-
CLEAR_PENDING
Statement clearing the pending columns of a user.- See Also:
-
DELETE_IF_EMPTY
Statement deleting the row of a user that holds neither a verified phone nor a pending verification.- See Also:
-
CLEAR_EXPIRED
Statement clearing every expired pending verification.- See Also:
-
DELETE_EMPTY_ROWS
Statement deleting the rows that hold nothing at all.- See Also:
-
jdbcClient
private final org.springframework.jdbc.core.simple.JdbcClient jdbcClientJDBC client used to run the statements. -
phoneVerificationRowMapper
Maps a row to a verification.
-
-
Constructor Details
-
JdbcPhoneVerificationRepository
public JdbcPhoneVerificationRepository()
-
-
Method Details
-
save
- Specified by:
savein interfacePhoneVerificationRepository
-
findByUserId
- Specified by:
findByUserIdin interfacePhoneVerificationRepository
-
incrementAttempts
- Specified by:
incrementAttemptsin interfacePhoneVerificationRepository
-
deleteByUserId
- Specified by:
deleteByUserIdin interfacePhoneVerificationRepository
-
deleteExpired
- Specified by:
deleteExpiredin interfacePhoneVerificationRepository
-