Commits

Luke Plant  committed c6b1201

Pass credentials to validateComment

  • Participants
  • Parent commits adf9b35

Comments (0)

Files changed (2)

File src/Blog/Forms.hs

 
 -- | extract the posted data from a POST request and build
 -- a Comment from it, returning a Comment and a list of validation errors
-validateComment postedData blogpost =
+validateComment creds postedData blogpost =
     do
     -- TODO - protect name -- some names are reserved for logged in users.
     -- TODO - posts that are closed for comments

File src/Blog/Views.hs

     handleUserComment cn post req =
         case requestMethod req of
           "POST" -> do
-            (commentData, commentErrors) <- validateComment (getPOST req) post
+            (commentData, commentErrors) <- validateComment (getCredentials req) (getPOST req) post
             if Map.null commentErrors
                then if isJust (getPOST req "submit")
                     then
 
 timeout = 3600 * 24 * 10 -- 10 days
 
+type Credentials = Maybe String
+
 -- | Return the username if logged in, otherwise Nothing
 --
 -- Relies on secure cookies middleware
-getCredentials :: Request -> IO (Maybe String)
+getCredentials :: Request -> IO Credentials
 getCredentials req = do
   current_ts <- getTimestamp
   return $ do