Commits

Luke Plant committed 6fd4ef4

Fixed sending of login cookies so that browsers accept them.

Also fixed redirect URL to something useful for now.

Comments (0)

Files changed (2)

src/Blog/Links.hs

 feedsUrl          = Settings.root_url ++ "feeds/"
 loginUrl          = Settings.root_url ++ "login/"
 
-adminMenuUrl      = Settings.root_url ++ "admin/"
+adminMenuUrl      = Settings.root_url 

src/Blog/Views.hs

 import Ella.Response
 import Ella.Utils (addHtml)
 import Maybe (fromMaybe, isJust, fromJust)
+import System.Time (ClockTime(..), toUTCTime)
 import qualified Blog.Settings as Settings
 import qualified Data.Map as Map
 
 standardCookie = Cookie { cookieName = ""
                         , cookieValue = ""
                         , cookieExpires = Nothing
-                        , cookieDomain = Just Settings.domain
-                        , cookiePath = Nothing
+                        , cookieDomain = Nothing
+                        , cookiePath = Just "/"
                         , cookieSecure = False
                         }
 
 createLoginCookies loginData timestamp =
   let username = fromJust $ Map.lookup "username" loginData
       password = fromJust $ Map.lookup "password" loginData
+      expires = Just $ toUTCTime $ TOD (toInteger timestamp + 3600*24*365) 0
   in [ standardCookie { cookieName = "username"
-                      , cookieValue = username }
+                      , cookieValue = username
+                      , cookieExpires = expires
+                      }
      , standardCookie { cookieName = "timestamp"
-                      , cookieValue = show timestamp }
-     , standardCookie { cookieName = "hash"
-                      , cookieValue = "TODO - sign the cookie" }
+                      , cookieValue = show timestamp
+                      , cookieExpires = expires
+                      }
      ]