mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 09:35:37 +00:00
36 lines
1010 B
TypeScript
36 lines
1010 B
TypeScript
import { useEffect } from "react";
|
|
import { useRouter } from "next/router";
|
|
import queryString from "query-string";
|
|
|
|
import AuthorizeIntegration from "../../../api/integrations/authorizeIntegration";
|
|
|
|
export default function VercelOAuth2CallbackPage() {
|
|
const router = useRouter();
|
|
|
|
const { code, state } = queryString.parse(router.asPath.split("?")[1]);
|
|
|
|
useEffect(() => {
|
|
(async () => {
|
|
try {
|
|
// validate state
|
|
if (state !== localStorage.getItem("latestCSRFToken")) return;
|
|
localStorage.removeItem("latestCSRFToken");
|
|
|
|
const integrationAuth = await AuthorizeIntegration({
|
|
workspaceId: localStorage.getItem("projectData.id") as string,
|
|
code: code as string,
|
|
integration: "vercel"
|
|
});
|
|
|
|
router.push(`/integrations/vercel/create?integrationAuthId=${integrationAuth._id}`);
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
})();
|
|
}, []);
|
|
|
|
return <div />;
|
|
}
|
|
|
|
VercelOAuth2CallbackPage.requireAuth = true;
|