diff options
| -rw-r--r-- | fig-web/src/Fig/Web/Auth.hs | 2 | ||||
| -rw-r--r-- | fig-web/src/Fig/Web/Module/User.hs | 14 | ||||
| -rw-r--r-- | fig-web/src/Fig/Web/Public.hs | 2 | ||||
| -rw-r--r-- | fig-web/src/Fig/Web/Secure.hs | 1 |
4 files changed, 16 insertions, 3 deletions
diff --git a/fig-web/src/Fig/Web/Auth.hs b/fig-web/src/Fig/Web/Auth.hs index 0e372c8..fa7f9d0 100644 --- a/fig-web/src/Fig/Web/Auth.hs +++ b/fig-web/src/Fig/Web/Auth.hs @@ -17,7 +17,7 @@ data Credentials = Credentials } authed :: SecureModuleArgs -> (Credentials -> Sc.ActionM ()) -> Sc.ActionM () authed args h | args.options.simAuth = do - let auth = Credentials { user = "fake_test_user", twitchId = "69" } + let auth = Credentials { user = "lcolonq", twitchId = "866686220" } h auth authed _ h = do muser <- header "Remote-User" diff --git a/fig-web/src/Fig/Web/Module/User.hs b/fig-web/src/Fig/Web/Module/User.hs index 90daa6f..e21afcf 100644 --- a/fig-web/src/Fig/Web/Module/User.hs +++ b/fig-web/src/Fig/Web/Module/User.hs @@ -67,9 +67,21 @@ public a = do status status404 respondText "user not found" Just val -> respondText $ decodeUtf8 val + onGet "/api/user-id/:name" do + name <- pathParam "name" + getText a.db ("user-id:" <> encodeUtf8 (Text.toLower name)) >>= \case + Nothing -> do + status status404 + respondText "username not found" + Just val -> respondText val onGet "/api/user/info/:uid" do -- get everything bundled together uid <- pathParam "uid" - respondJSON =<< getUserInfo a.db uid + info <- getUserInfo a.db uid + case Map.lookup "name" info.properties of + Just _ -> respondJSON info + Nothing -> do + status status404 + respondText "no such user" onGet "/api/user/stats/:uid" do uid <- pathParam "uid" respondJSON =<< getIntegerValuedMap a.db ("user:stats:" <> uid) diff --git a/fig-web/src/Fig/Web/Public.hs b/fig-web/src/Fig/Web/Public.hs index 4a929e9..69678bb 100644 --- a/fig-web/src/Fig/Web/Public.hs +++ b/fig-web/src/Fig/Web/Public.hs @@ -66,7 +66,7 @@ app args = do , ("gizmo", "gizmo.html") , ("advent", "advent.html") , ("debt", "debtclock.html") - , ("charsheet", "charsheet.html") + , ("charsheet", "charsheet-public.html") , ("main.js", "main.js") ] Wai.Static.<|> Wai.Static.hasPrefix "assets" , Wai.Static.addBase args.cfg.assetPath diff --git a/fig-web/src/Fig/Web/Secure.hs b/fig-web/src/Fig/Web/Secure.hs index 628cd56..b5d3299 100644 --- a/fig-web/src/Fig/Web/Secure.hs +++ b/fig-web/src/Fig/Web/Secure.hs @@ -55,6 +55,7 @@ app args = do , ("soundboard", "soundboard.html") , ("throwshade", "throwshade.html") , ("advent", "advent.html") + , ("charedit", "charsheet-private.html") , ("main.js", "main.js") ] Wai.Static.<|> Wai.Static.hasPrefix "assets" |
