Luke Plant avatar 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
+                      }
      ]
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.