aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/settings/square/+page.server.ts
blob: 5d4c21e66aabdde17224d18d7c35f4f4f567f40c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { auth, get } from "$lib/utils";
import { fail, redirect } from "@sveltejs/kit";

export async function load({ cookies, url }) {
  let connected;

  const query = url.searchParams.toString();

  try {
    await get(`/square/auth?${query}`, auth(cookies));
    connected = true;
  } catch (e) {
    const { message } = e as Error;
    fail(400, { message });
  }

  if (connected) redirect(307, "/settings/account");
}