Fix onboarding OAuth callback glitch (#1079)

This commit is contained in:
Alex Johansson
2021-11-03 10:47:52 +00:00
committed by GitHub
parent d147772d91
commit a002b194da
7 changed files with 66 additions and 33 deletions
+21
View File
@@ -0,0 +1,21 @@
import { NextApiRequest } from "next";
import { IntegrationOAuthCallbackState } from "./types";
export function encodeOAuthState(req: NextApiRequest) {
if (typeof req.query.state !== "string") {
return undefined;
}
const state: IntegrationOAuthCallbackState = JSON.parse(req.query.state);
return JSON.stringify(state);
}
export function decodeOAuthState(req: NextApiRequest) {
if (typeof req.query.state !== "string") {
return undefined;
}
const state: IntegrationOAuthCallbackState = JSON.parse(req.query.state);
return state;
}