Cleanup JWT expires

This commit is contained in:
calebmer
2015-11-11 08:34:50 -05:00
parent aab2f0d1f1
commit 62cb8e0453
4 changed files with 13 additions and 14 deletions
+3 -2
View File
@@ -18,6 +18,7 @@ module PostgREST.Auth (
, tokenJWT
) where
import Control.Monad (join)
import Data.Aeson (Value (..), Object)
import Data.Aeson.Types (emptyObject, emptyArray)
import Data.Vector as V (null, head)
@@ -52,8 +53,8 @@ claimsToSQL = map setVar . toList
-}
jwtClaims :: Text -> Text -> NominalDiffTime -> Maybe JWT.ClaimsMap
jwtClaims secret input time =
case claim JWT.exp of
Just (Just expires) ->
case join $ claim JWT.exp of
Just expires ->
if JWT.secondsSinceEpoch expires > time
then customClaims
else Nothing