aboutsummaryrefslogtreecommitdiff
path: root/src/server/Controller/User.hs
blob: 1baab18ba44b8baaf010a07c8fc3185e6aaf9250 (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
26
27
{-# LANGUAGE OverloadedStrings #-}

module Controller.User
  ( getUsers
  , whoAmI
  ) where

import Web.Scotty

import Control.Monad.IO.Class (liftIO)

import qualified Secure

import Model.Database
import qualified Model.User as U

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

whoAmI :: ActionM ()
whoAmI =
  Secure.loggedAction (\user ->
    json (U.getJsonUser user)
  )