From f6446aec725234ea38b5431defa8e4c987e07f20 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 13 Mar 2012 21:29:06 +0100 Subject: [PATCH] * added flushSessions :: IO() * updated TODO --- TODO | 3 +-- src/BlogDB.hs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index b64487438..7b2c54f44 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ * handle BlogErrors * fix sessions -* add readMore link -* add flushSessions :: IO() \ No newline at end of file +* add readMore link \ No newline at end of file diff --git a/src/BlogDB.hs b/src/BlogDB.hs index 9bffd79c3..d5a964da8 100644 --- a/src/BlogDB.hs +++ b/src/BlogDB.hs @@ -168,6 +168,12 @@ getSession sId = do b@Blog{..} <- ask return $ getOne $ blogSessions @= sId +clearSessions :: Update Blog [Session] +clearSessions = + do b@Blog{..} <- get + put $ b { blogSessions = empty } + return [] + addUser :: Text -> String -> Update Blog User addUser un pw = do b@Blog{..} <- get @@ -203,6 +209,7 @@ $(makeAcidic ''Blog , 'addUser , 'getUser , 'checkUser + , 'clearSessions ]) interactiveUserAdd :: IO () @@ -215,3 +222,10 @@ interactiveUserAdd = do pw <- getLine update' acid (AddUser (pack un) pw) createCheckpointAndClose acid + +flushSessions :: IO () +flushSessions = do + tbDir <- getEnv "TAZBLOG" + acid <- openLocalStateFrom (tbDir ++ "/BlogState") initialBlogState + update' acid (ClearSessions) + createCheckpointAndClose acid