about summary refs log tree commit diff
path: root/src/BlogDB.hs
diff options
context:
space:
mode:
authorVincent Ambo <v.ambo@me.com>2012-03-13T05·35+0100
committerVincent Ambo <v.ambo@me.com>2012-03-13T05·35+0100
commit2cb2900b0747dfb83ebc78e7f129bd26fba920fe (patch)
treefc3606210ac5d14b38d4259842d576355f8ba16c /src/BlogDB.hs
parent6092eb6f5e095c7a20f64e4149399391506dd9a0 (diff)
* updated some stuff, work on sessions
Diffstat (limited to 'src/BlogDB.hs')
-rw-r--r--src/BlogDB.hs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/BlogDB.hs b/src/BlogDB.hs
index cade9327e7f1..9bffd79c3b30 100644
--- a/src/BlogDB.hs
+++ b/src/BlogDB.hs
@@ -16,7 +16,7 @@ import Data.SafeCopy        (SafeCopy, base, deriveSafeCopy)
 import Data.Text            (Text, pack)
 import Data.Text.Lazy       (toStrict)
 import Data.Time
-import Happstack.Server 	(ServerPart)
+import System.Environment(getEnv)
 
 import qualified Crypto.Hash.SHA512 as SHA (hash)
 import qualified Data.ByteString.Char8 as B
@@ -157,12 +157,11 @@ latestEntries lang =
     do b@Blog{..} <- ask
        return $ IxSet.toDescList (Proxy :: Proxy EDate) $ blogEntries @= lang
 
-addSession :: Text -> User -> UTCTime -> Update Blog Session
-addSession sId u t =
+addSession :: Session -> Update Blog Session
+addSession nSession =
     do b@Blog{..} <- get
-       let s = Session sId u t
-       put $ b { blogSessions = IxSet.insert s blogSessions}
-       return s
+       put $ b { blogSessions = IxSet.insert nSession blogSessions}
+       return nSession
 
 getSession :: SessionID -> Query Blog (Maybe Session)
 getSession sId =
@@ -206,3 +205,13 @@ $(makeAcidic ''Blog
     , 'checkUser
     ])
 
+interactiveUserAdd :: IO ()
+interactiveUserAdd = do
+  tbDir <- getEnv "TAZBLOG"
+  acid <- openLocalStateFrom (tbDir ++ "/BlogState") initialBlogState
+  putStrLn "Username:"
+  un <- getLine
+  putStrLn "Password:"
+  pw <- getLine
+  update' acid (AddUser (pack un) pw)
+  createCheckpointAndClose acid