From cf37e19f281143ff6f9a35d45b7911e65fb8e98d Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Tue, 6 Oct 2020 14:38:33 +0100 Subject: When a code is received post it back to the opener --- src/pages/CallbackPage.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/pages/CallbackPage.tsx (limited to 'src') diff --git a/src/pages/CallbackPage.tsx b/src/pages/CallbackPage.tsx new file mode 100644 index 0000000..caa384f --- /dev/null +++ b/src/pages/CallbackPage.tsx @@ -0,0 +1,17 @@ +/** @jsx jsx */ +import { jsx } from "@emotion/core"; +import { useState } from "react"; + +export default function CallbackPage() { + const [hasSent, setHasSent] = useState(false); + const params = new URLSearchParams(document.location.search); + + const code = params.get("code"); + + if (!hasSent) { + setHasSent(true); + window.opener.postMessage(code); + } + + return

Code is {code}

; +} -- cgit v1.2.3