diff options
| author | LLLL Colonq <llll@colonq> | 2024-11-26 00:07:24 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2024-11-26 00:07:24 -0500 |
| commit | 752d486ef5a4ae85ac04aae3bd74785cab52c137 (patch) | |
| tree | 42896017b31ec220805b09c02620a009d7eb7e51 /fig-web/src/Fig/Web/Secure.hs | |
| parent | ac935be98ed4c31c83be0afbcc6da827937c950e (diff) | |
Change redeem endpoint to use Remote-User header
Diffstat (limited to 'fig-web/src/Fig/Web/Secure.hs')
| -rw-r--r-- | fig-web/src/Fig/Web/Secure.hs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/fig-web/src/Fig/Web/Secure.hs b/fig-web/src/Fig/Web/Secure.hs index e40204c..e02d503 100644 --- a/fig-web/src/Fig/Web/Secure.hs +++ b/fig-web/src/Fig/Web/Secure.hs @@ -5,6 +5,7 @@ module Fig.Web.Secure where import Fig.Prelude import qualified Data.Text as Text +import qualified Data.Text.Lazy as Text.Lazy import qualified Data.ByteString.Base64 as BS.Base64 import qualified Data.Set as Set @@ -60,18 +61,22 @@ app cfg cmds = do Sc.get "/api/status" do Sc.text "this is the secure endpoint" Sc.post "/api/redeem" do - headers <- Sc.headers - log $ tshow headers - me <- Text.toLower <$> Sc.formParam "ayem" - name <- Sc.formParam "name" - input <- Sc.formParamMaybe "input" - liftIO $ cmds.publish [sexp|(frontend redeem incoming)|] - $ mconcat - [ [ sexprStr me - , sexprStr name - ] - , maybe [] ((:[]) . sexprStr) input - ] - Sc.text "it worked" + muser <- Sc.header "Remote-User" + memail <- Sc.header "Remote-Email" + case (muser, memail) of + (Just user, Just email) -> do + name <- Sc.formParam "name" + input <- Sc.formParamMaybe "input" + liftIO $ cmds.publish [sexp|(frontend redeem incoming)|] + $ mconcat + [ [ sexprStr $ Text.Lazy.toStrict user + , sexprStr name + ] + , maybe [] ((:[]) . sexprStr) input + ] + Sc.text "it worked" + _else -> do + Sc.status status401 + Sc.text "you're not logged in buddy" Sc.notFound do Sc.text "not found" |
