Add `checkuser` endpoint

This commit is contained in:
Rene Vergara 2023-05-11 11:36:28 -05:00
parent e80411d8bd
commit f68675af03
Signed by: pitmutt
GPG Key ID: 65122AD495A7F5B2
1 changed files with 10 additions and 3 deletions

View File

@ -844,13 +844,20 @@ routes pipe config = do
status accepted202
Web.Scotty.json
(object ["message" .= ("Incorrect plugin config" :: String)])
get "/checkuser" $ do
sess <- param "session"
user <- liftAndCatchIO $ run (findUser sess)
case user of
Nothing -> status noContent204
Just u -> status ok200
--Get user associated with session
get "/api/user" $ do
sess <- param "session"
user <- liftAndCatchIO $ run (findUser sess)
case user of
Nothing -> status noContent204
Just u ->
Just u -> do
status ok200
Web.Scotty.json
(object
[ "message" .= ("User found" :: String)
@ -891,7 +898,7 @@ routes pipe config = do
status ok200
else status noContent204
--Get current blockheight from Zcash node
get "/api/blockheight" $ do
get "/blockheight" $ do
blockInfo <-
liftAndCatchIO $ makeZcashCall nodeUser nodePwd "getblock" ["-1"]
let content = getResponseBody blockInfo :: RpcResponse Block
@ -902,7 +909,7 @@ routes pipe config = do
else do
status internalServerError500
--Get the ZGo node's shielded address
get "/api/getaddr" $ do Web.Scotty.json (object ["addr" .= nodeAddress])
get "/getaddr" $ do Web.Scotty.json (object ["addr" .= nodeAddress])
--Get owner by address
get "/api/owner" $ do
addr <- param "address"