From e8c7bf9c0ce6a14a6d9933111c32a73d708951bf Mon Sep 17 00:00:00 2001 From: Ben Kremer Date: Sat, 17 Sep 2022 11:34:03 +0200 Subject: [PATCH] refactor(auth-dapp): narrow type on `auth_response` handler --- dapps/react-dapp-auth/pages/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dapps/react-dapp-auth/pages/index.tsx b/dapps/react-dapp-auth/pages/index.tsx index 019762e..18c9c7f 100644 --- a/dapps/react-dapp-auth/pages/index.tsx +++ b/dapps/react-dapp-auth/pages/index.tsx @@ -48,10 +48,16 @@ const Home: NextPage = () => { useEffect(() => { if (!client) return; - client.on("auth_response", (res) => { - if (res.params.result.s) { - setAddress(res.params.result.p.iss.split(":")[4]); + client.on("auth_response", ({ params }) => { + if ("code" in params) { + console.error(params); + return; } + if ("error" in params) { + console.error(params.error); + return; + } + setAddress(params.result.p.iss.split(":")[4]); }); }, [client]);