feat: link discord account to existing account

This commit is contained in:
sam 2024-11-03 13:53:16 +01:00
parent c4cb08cdc1
commit 201c56c3dd
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
12 changed files with 333 additions and 14 deletions

View file

@ -0,0 +1,26 @@
import { LoaderFunctionArgs, redirect, json } from "@remix-run/node";
import serverRequest, { getToken } from "~/lib/request.server";
import { ApiError } from "~/lib/api/error";
import { useLoaderData } from "@remix-run/react";
import ErrorAlert from "~/components/ErrorAlert";
export const loader = async ({ request }: LoaderFunctionArgs) => {
const token = getToken(request);
try {
const { url } = await serverRequest<{ url: string }>("GET", "/auth/discord/add-account", {
isInternal: true,
token,
});
return redirect(url, 303);
} catch (e) {
return json({ error: e as ApiError });
}
};
export default function AddDiscordAccountPage() {
const { error } = useLoaderData<typeof loader>();
return <ErrorAlert error={error} />;
}