aboutsummaryrefslogtreecommitdiff
path: root/src/server/Controller/User.hs
blob: 95e5fa85f5dc0a14abc9e257cb1f84ecaf383c56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Controller.User
  ( getUsersAction
  , whoAmIAction
  ) where

import Web.Scotty

import Control.Monad.IO.Class (liftIO)

import qualified Secure

import Model.Database
import Model.User

getUsersAction :: ActionM ()
getUsersAction =
  Secure.loggedAction (\_ -> do
    (liftIO $ map getJsonUser <$> runDb getUsers) >>= json
  )

whoAmIAction :: ActionM ()
whoAmIAction =
  Secure.loggedAction (\user -> do
    json (getJsonUser user)
  )