aboutsummaryrefslogtreecommitdiff
path: root/src/server/Secure.hs
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-07-18 17:36:35 +0200
committerJoris Guyonvarch2015-07-18 17:36:35 +0200
commitb27a7914993f5a5a87160dc33431a6fa1f4ad323 (patch)
tree656447c17b61c0449fed21ef383c8910be365a79 /src/server/Secure.hs
parent89dd4de13896f8e37d1bf133080eb881ab42b292 (diff)
downloadbudget-b27a7914993f5a5a87160dc33431a6fa1f4ad323.tar.gz
budget-b27a7914993f5a5a87160dc33431a6fa1f4ad323.tar.bz2
budget-b27a7914993f5a5a87160dc33431a6fa1f4ad323.zip
Securing the index page with the login session
Diffstat (limited to 'src/server/Secure.hs')
-rw-r--r--src/server/Secure.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/server/Secure.hs b/src/server/Secure.hs
new file mode 100644
index 0000000..94ee8a9
--- /dev/null
+++ b/src/server/Secure.hs
@@ -0,0 +1,23 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Secure
+ ( loggedAction
+ ) where
+
+import Web.Scotty
+
+import Network.HTTP.Types.Status (forbidden403)
+
+import Data.Text (Text)
+
+import qualified LoginSession
+
+loggedAction :: (Text -> ActionM ()) -> ActionM ()
+loggedAction action = do
+ maybeLogin <- LoginSession.get
+ case maybeLogin of
+ Just login ->
+ action login
+ Nothing -> do
+ status forbidden403
+ html "You need to be logged in to perform this action"