From 022ead8b316ed6be939dd9712c080ab678bdec53 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Sun, 16 May 2010 10:15:29 +0300 Subject: [PATCH] clientsession 0.4 --- Yesod/Dispatch.hs | 8 ++++---- Yesod/Yesod.hs | 5 ++--- yesod.cabal | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Yesod/Dispatch.hs b/Yesod/Dispatch.hs index 45c298ee..b2dbf7ee 100644 --- a/Yesod/Dispatch.hs +++ b/Yesod/Dispatch.hs @@ -186,7 +186,7 @@ toWaiApp' y segments env = do let eurl' = either (const Nothing) Just eurl let eh er = runHandler (errorHandler y er) render eurl' id y id (s, hs, ct, c, sessionFinal) <- unYesodApp ya eh rr types - sessionVal <- encodeSession key' exp' host sessionFinal + let sessionVal = encodeSession key' exp' host sessionFinal let hs' = AddCookie (clientSessionDuration y) sessionName sessionVal : hs hs'' = map (headerToPair getExpires) hs' @@ -288,15 +288,15 @@ headerToPair _ (DeleteCookie key) = key ++ "=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT") headerToPair _ (Header key value) = (W.responseHeaderFromBS $ cs key, cs value) -encodeSession :: B.ByteString -- ^ key +encodeSession :: Key -> UTCTime -- ^ expire time -> B.ByteString -- ^ remote host -> [(String, String)] -- ^ session - -> IO String -- ^ cookie value + -> String -- ^ cookie value encodeSession key expire rhost session' = encrypt key $ cs $ encode $ SessionCookie expire rhost session' -decodeSession :: B.ByteString -- ^ key +decodeSession :: Key -> UTCTime -- ^ current time -> B.ByteString -- ^ remote host field -> B.ByteString -- ^ cookie value diff --git a/Yesod/Yesod.hs b/Yesod/Yesod.hs index f8753be2..78fc216c 100644 --- a/Yesod/Yesod.hs +++ b/Yesod/Yesod.hs @@ -20,8 +20,7 @@ import Data.Convertible.Text import qualified Network.Wai as W import Yesod.Json import Yesod.Internal -import Web.ClientSession (getKey, defaultKeyFile) -import Data.ByteString (ByteString) +import Web.ClientSession (getKey, defaultKeyFile, Key) import Web.Routes.Quasi (QuasiSite (..), Routes) @@ -46,7 +45,7 @@ class Yesod a where approot :: a -> String -- | The encryption key to be used for encrypting client sessions. - encryptKey :: a -> IO ByteString + encryptKey :: a -> IO Key encryptKey _ = getKey defaultKeyFile -- | Number of minutes before a client session times out. Defaults to diff --git a/yesod.cabal b/yesod.cabal index d3f240e1..952e884e 100644 --- a/yesod.cabal +++ b/yesod.cabal @@ -45,7 +45,7 @@ library web-routes-quasi >= 0.2 && < 0.3, hamlet >= 0.2.2 && < 0.3, transformers >= 0.1 && < 0.3, - clientsession >= 0.3.0 && < 0.4, + clientsession >= 0.4.0 && < 0.5, MonadCatchIO-transformers >= 0.2.2 && < 0.3, pureMD5 >= 1.1.0.0 && < 1.2, random >= 1.0.0.2 && < 1.1,