From 1216c472c75ffb6196f29362796737281ae55976 Mon Sep 17 00:00:00 2001 From: Felipe Lessa Date: Wed, 21 Mar 2012 14:36:30 -0300 Subject: [PATCH 1/2] Remove trailing whitespace. --- yesod-core/Yesod/Internal/Core.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/yesod-core/Yesod/Internal/Core.hs b/yesod-core/Yesod/Internal/Core.hs index 4538ea83..5fb9d7af 100644 --- a/yesod-core/Yesod/Internal/Core.hs +++ b/yesod-core/Yesod/Internal/Core.hs @@ -227,8 +227,8 @@ class RenderRoute a => Yesod a where where corrected = filter (not . T.null) s - -- | Builds an absolute URL by concatenating the application root with the - -- pieces of a path and a query string, if any. + -- | Builds an absolute URL by concatenating the application root with the + -- pieces of a path and a query string, if any. -- Note that the pieces of the path have been previously cleaned up by 'cleanPath'. joinPath :: a -> T.Text -- ^ application root @@ -368,7 +368,7 @@ formatLogMessage loc level msg = do -- turn the TH Loc loaction information into a human readable string -- leaving out the loc_end parameter fileLocationToString :: Loc -> String -fileLocationToString loc = (loc_package loc) ++ ':' : (loc_module loc) ++ +fileLocationToString loc = (loc_package loc) ++ ':' : (loc_module loc) ++ ' ' : (loc_filename loc) ++ ':' : (line loc) ++ ':' : (char loc) where line = show . fst . loc_start @@ -704,7 +704,7 @@ defaultClientSessionBackend = do let timeout = 120 -- 120 minutes return $ clientSessionBackend key timeout -clientSessionBackend :: Yesod master +clientSessionBackend :: Yesod master => CS.Key -- ^ The encryption key -> Int -- ^ Inactive session valitity in minutes -> SessionBackend master @@ -737,7 +737,7 @@ saveClientSession :: Yesod master saveClientSession key timeout master _ now _ sess = do -- fixme should we be caching this? iv <- liftIO $ CS.randomIV - return [AddCookie def + return [AddCookie def { setCookieName = sessionName , setCookieValue = sessionVal iv , setCookiePath = Just (cookiePath master) From 9cd7a0ba14175f315ee6556bd9306ab6608b6daf Mon Sep 17 00:00:00 2001 From: Felipe Lessa Date: Wed, 21 Mar 2012 14:36:46 -0300 Subject: [PATCH 2/2] Add cookieDomain to Yesod type class. --- yesod-core/Yesod/Internal/Core.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/yesod-core/Yesod/Internal/Core.hs b/yesod-core/Yesod/Internal/Core.hs index 5fb9d7af..89ebca32 100644 --- a/yesod-core/Yesod/Internal/Core.hs +++ b/yesod-core/Yesod/Internal/Core.hs @@ -274,6 +274,12 @@ class RenderRoute a => Yesod a where cookiePath :: a -> S8.ByteString cookiePath _ = "/" + -- | The domain value to set for cookies. By default, the + -- domain is not set, meaning cookies will be sent only to + -- the current domain. + cookieDomain :: a -> Maybe S8.ByteString + cookieDomain _ = Nothing + -- | Maximum allowed length of the request body, in bytes. maximumContentLength :: a -> Maybe (Route a) -> Int maximumContentLength _ _ = 2 * 1024 * 1024 -- 2 megabytes @@ -742,7 +748,7 @@ saveClientSession key timeout master _ now _ sess = do , setCookieValue = sessionVal iv , setCookiePath = Just (cookiePath master) , setCookieExpires = Just expires - , setCookieDomain = Nothing + , setCookieDomain = cookieDomain master , setCookieHttpOnly = True }] where