diff options
Diffstat (limited to 'src/server/Model')
-rw-r--r-- | src/server/Model/SignIn.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/server/Model/SignIn.hs b/src/server/Model/SignIn.hs index 0f9c6ce..117b8b5 100644 --- a/src/server/Model/SignIn.hs +++ b/src/server/Model/SignIn.hs @@ -2,6 +2,7 @@ module Model.SignIn ( createSignInToken , getSignInToken , signInTokenToUsed + , isLastValidToken ) where import Data.Text (Text) @@ -28,3 +29,12 @@ getSignInToken token = signInTokenToUsed :: SignInId -> Persist () signInTokenToUsed tokenId = update tokenId [SignInIsUsed =. True] + +isLastValidToken :: SignIn -> Persist Bool +isLastValidToken signIn = do + maybe False ((== (signInToken signIn)) . signInToken . entityVal) <$> + selectFirst + [ SignInEmail ==. (signInEmail signIn) + , SignInIsUsed ==. True + ] + [ Desc SignInCreation ] |