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

View file

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