🐛 Use current origin as base url for code verification (#925)

This commit is contained in:
Luke Vella 2023-10-30 19:41:45 +00:00 committed by GitHub
parent 1b5543d20c
commit faaf21c08a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,7 +7,6 @@ import React from "react";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import { createGlobalState } from "react-use"; import { createGlobalState } from "react-use";
import { absoluteUrl } from "@/utils/absolute-url";
import { usePostHog } from "@/utils/posthog"; import { usePostHog } from "@/utils/posthog";
import { trpc } from "@/utils/trpc/client"; import { trpc } from "@/utils/trpc/client";
@ -17,7 +16,11 @@ import { TextInput } from "../text-input";
export const useDefaultEmail = createGlobalState(""); export const useDefaultEmail = createGlobalState("");
const verifyCode = async (options: { email: string; token: string }) => { const verifyCode = async (options: { email: string; token: string }) => {
const url = absoluteUrl("/api/auth/callback/email", options); const url = `${
window.location.origin
}/api/auth/callback/email?email=${encodeURIComponent(options.email)}&token=${
options.token
}`;
const res = await fetch(url); const res = await fetch(url);
@ -159,7 +162,7 @@ export const LoginForm: React.FunctionComponent<{
}); });
} }
posthog?.capture("login", { posthog?.capture("login", {
method: "verification-code" method: "verification-code",
}); });
router.push(callbackUrl); router.push(callbackUrl);
} }