Source

haskellblog / src / Blog / Views.hs

Diff from to

src/Blog/Views.hs

 
 -- | Delete auth cookies and redirect.
 logoutView req =
-    return $ Just $ (redirectResponse indexUrl) `with` [ deleteCookie "username"
-                                                       , deleteCookie "timestamp"
-                                                       ]
+    return $ Just $ deleteCookie "username" $ redirectResponse indexUrl
 
 --
 -- Admin views
 -- Authentication
 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
+      expires = Just $ toUTCTime $ TOD (toInteger timestamp + Settings.login_session_length) 0
   in [ standardCookie { cookieName = "username"
                       , cookieValue = username
                       , cookieExpires = expires
                       }
-     , standardCookie { cookieName = "timestamp"
-                      , cookieValue = show timestamp
-                      , cookieExpires = expires
-                      }
      ]
 
 
 -- Relies on secure cookies middleware
 getCredentials :: Request -> IO Credentials
 getCredentials req = do
-  current_ts <- getTimestamp
-  return $ do
-    username <- getCookieVal req "username"
-    timestamp <- getCookieVal req "timestamp" >>= capture
-    if timestamp + timeout > current_ts
-      then Just username
-      else Nothing
-
+  return $ getCookieVal req "username"
 
 -- Decorators