diff options
Diffstat (limited to 'src/server/Secure.hs')
-rw-r--r-- | src/server/Secure.hs | 23 |
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" |