Copyright | (c) Anton Gushcha 2016 |
---|---|
License | MIT |
Maintainer | ncrashed@gmail.com |
Stability | experimental |
Portability | Portable |
Safe Haskell | None |
Language | Haskell2010 |
- makeSingleUseExpire :: MonadIO m => NominalDiffTime -> m UTCTime
- registerSingleUseCode :: HasStorage m => UserImplId -> SingleUseCode -> Maybe UTCTime -> m ()
- invalidateSingleUseCode :: HasStorage m => UserSingleUseCodeId -> m ()
- validateSingleUseCode :: HasStorage m => UserImplId -> SingleUseCode -> m Bool
- generateSingleUsedCodes :: HasStorage m => UserImplId -> IO SingleUseCode -> Word -> m [SingleUseCode]
Documentation
:: MonadIO m | |
=> NominalDiffTime | Duration of code |
-> m UTCTime | Time when the code expires |
Calculate expire date for single usage code
registerSingleUseCode Source #
:: HasStorage m | |
=> UserImplId | Id of user |
-> SingleUseCode | Single usage code |
-> Maybe UTCTime | Time when the code expires, |
-> m () |
Register single use code in DB
invalidateSingleUseCode Source #
:: HasStorage m | |
=> UserSingleUseCodeId | Id of code |
-> m () |
Marks single use code that it cannot be used again
validateSingleUseCode Source #
:: HasStorage m | |
=> UserImplId | Id of user |
-> SingleUseCode | Single usage code |
-> m Bool |
Check single use code and return True
on success.
On success invalidates single use code.
generateSingleUsedCodes Source #
:: HasStorage m | |
=> UserImplId | Id of user |
-> IO SingleUseCode | Generator of codes |
-> Word | |
-> m [SingleUseCode] |
Generates a set single use codes that doesn't expire.
Note: previous codes without expiration are invalidated.