aboutsummaryrefslogtreecommitdiff
path: root/src/server/Secure.hs
blob: 94ee8a94e5eee00a81532c23842d7284326a0d6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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"