diff options
author | Joris | 2015-11-01 19:47:24 +0100 |
---|---|---|
committer | Joris | 2015-11-01 19:47:24 +0100 |
commit | 51d1ff2273315ad1270794499d0c49e8fb99aba5 (patch) | |
tree | 8a3027d9fe2865731e0111989bc84eaea1591270 /src/server/Model | |
parent | f76aaedd794f15d9f049f53a081710b9565fb8b1 (diff) |
Store the sign in token instead of the login in the session cookie
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 ] |