diff options
| author | LLLL Colonq <llll@colonq> | 2025-05-30 02:55:35 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-05-30 02:55:55 -0400 |
| commit | f95d9bbde51ee26468177b2d34c669d9689fbea4 (patch) | |
| tree | 9790f7a39c70e1cc2c6a0d418ace38dcf7a1aa51 /fig-web/src/Fig/Web/Auth.hs | |
| parent | bab19289fd0b0f7a26056c4f20b5a0f456c9bf57 (diff) | |
web: Big refactor part 2
Diffstat (limited to 'fig-web/src/Fig/Web/Auth.hs')
| -rw-r--r-- | fig-web/src/Fig/Web/Auth.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fig-web/src/Fig/Web/Auth.hs b/fig-web/src/Fig/Web/Auth.hs new file mode 100644 index 0000000..5017b3e --- /dev/null +++ b/fig-web/src/Fig/Web/Auth.hs @@ -0,0 +1,27 @@ +module Fig.Web.Auth + ( Credentials(..) + , authed + ) where + +import Fig.Prelude + +import qualified Web.Scotty as Sc + +import Fig.Web.Types +import Fig.Web.Utils + +data Credentials = Credentials + { user :: Text + , email :: Text + } +authed :: SecureModuleArgs -> (Credentials -> Sc.ActionM ()) -> Sc.ActionM () +authed args h = do + muser <- header "Remote-User" + memail <- header "Remote-Email" + case (muser, memail) of + (Just user, Just email) -> do + let auth = Credentials{..} + h auth + _else -> do + status status401 + respondText "you're not logged in buddy (this is probably a bug, go message clonk)" |
