aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2020-10-06 14:38:33 +0100
committerGravatar Joe Banks <[email protected]>2020-10-06 14:38:33 +0100
commitcf37e19f281143ff6f9a35d45b7911e65fb8e98d (patch)
tree403dd0e160264f9f8db13dfb9a2a7b308d74874e
parentOn OAuth2 button click pop open Discord authorize window (diff)
When a code is received post it back to the opener
-rw-r--r--src/pages/CallbackPage.tsx17
1 files changed, 17 insertions, 0 deletions
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 <p>Code is {code}</p>;
+}