summaryrefslogtreecommitdiff
path: root/fig-web/src/Fig/Web/Module/Redeem.hs
blob: 7dbafc0724e23b6afadc541ccc7ff9be7fd81cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Fig.Web.Module.Redeem
  ( secure
  ) where

import Fig.Prelude

import qualified Data.Maybe as Maybe
import qualified Data.Text as Text

import Fig.Web.Utils
import Fig.Web.Types

secure :: Module
secure a = do
  onPost "/api/redeem" $ authed \creds -> do
    name <- formParam "name"
    input <- formParamMaybe "input"
    liftIO . a.cmds.publish "frontend redeem incoming"
      . encodeUtf8 . Text.intercalate "\t" $
      [ creds.user
      , name
      ] <> Maybe.maybeToList input
    respondText "it worked"