From f68675af034579f2137abb190f6a551eea0e2bc9 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 11 May 2023 11:36:28 -0500 Subject: [PATCH] Add `checkuser` endpoint --- src/ZGoBackend.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index 99a6a49..e1e6749 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -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"