Interface EmailCodeRepository
- All Known Implementing Classes:
InMemoryEmailCodeRepository, JdbcEmailCodeRepository
public interface EmailCodeRepository
Where
EmailCodeService keeps who signs in with a mailed code, and the
hash of the code each is waiting to enter.-
Method Summary
Modifier and TypeMethodDescriptionbooleanUses the waiting code up, if it is still the one withcodeHash.booleancountAttempt(String username, int max) Counts one attempt against the waiting code.What is held forusername, or null.booleanKeeps a new code forusernamein place of the one waiting, when the user signs in with a mailed code and the last was sent at or beforesentBefore-- or aftersentAt, which is a clock that was set back.voidsetEnabled(String username, boolean enabled) Turns the mailed code on or off forusername.
-
Method Details
-
find
-
setEnabled
Turns the mailed code on or off forusername. Turning it off drops any code that is waiting. -
saveCode
boolean saveCode(String username, String codeHash, long expiresAt, long sentAt, long sentBefore, int max) Keeps a new code for
usernamein place of the one waiting, when the user signs in with a mailed code and the last was sent at or beforesentBefore-- or aftersentAt, which is a clock that was set back. Of several callers at once one is answered true, so one mail leaves.The attempts counted against the code it replaces are counted against this one too, unless that code had run out or been used: asking for another is not a way to more tries. And a code with
maxattempts counted is not replaced before it runs out, so the wait that follows them ends at a moment that asking again does not move. -
countAttempt
Counts one attempt against the waiting code. False whenmaxhave been counted already; of several callers at once, no more thanmaxare answered true. -
clear
Uses the waiting code up, if it is still the one withcodeHash. Of two callers with the same code, one is answered true.signedInsays the code was typed in and accepted, which also forgets when it was sent: the next sign-in is then mailed a code at once. A code cleared because its mail failed keeps the time, so a failing send is still spaced out.
-