Skip to content

Scheduling infrastructure for absolutely everyone.

use `getSession()` from `@lib/auth` everywhere (#563)

Alex Johansson2f1ede9bcddd
diff --git a/pages/api/availability/eventtype.ts b/pages/api/availability/eventtype.ts
index 71aab6aeba7..2125d47f420 100644
--- a/pages/api/availability/eventtype.ts
+++ b/pages/api/availability/eventtype.ts
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import prisma from "@lib/prisma";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
diff --git a/pages/api/availability/week.ts b/pages/api/availability/week.ts
index f0cd408e404..2ac55c0cdd5 100644
--- a/pages/api/availability/week.ts
+++ b/pages/api/availability/week.ts
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import prisma from "../../../lib/prisma";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
diff --git a/pages/api/book/confirm.ts b/pages/api/book/confirm.ts
index 54bc7552560..f84dd1ae253 100644
--- a/pages/api/book/confirm.ts
+++ b/pages/api/book/confirm.ts
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import prisma from "../../../lib/prisma";
import { handleLegacyConfirmationMail } from "./[user]";
import { CalendarEvent } from "@lib/calendarClient";
diff --git a/pages/api/integrations/caldav/add.ts b/pages/api/integrations/caldav/add.ts
index 06b2bdddf75..2c848b20702 100644
--- a/pages/api/integrations/caldav/add.ts
+++ b/pages/api/integrations/caldav/add.ts
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import prisma from "../../../../lib/prisma";
import { symmetricEncrypt } from "@lib/crypto";
import logger from "@lib/logger";
diff --git a/pages/api/integrations/zoomvideo/callback.ts b/pages/api/integrations/zoomvideo/callback.ts
index fb379cbbcf4..5a15cc96985 100644
--- a/pages/api/integrations/zoomvideo/callback.ts
+++ b/pages/api/integrations/zoomvideo/callback.ts
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import prisma from "../../../../lib/prisma";
const client_id = process.env.ZOOM_CLIENT_ID;
diff --git a/pages/api/schedule/index.ts b/pages/api/schedule/index.ts
index 8b3e088a0b4..651989dd9ac 100644
--- a/pages/api/schedule/index.ts
+++ b/pages/api/schedule/index.ts
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import prisma from "@lib/prisma";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
diff --git a/pages/api/teams.ts b/pages/api/teams.ts
index b386832fa29..b189b6a907e 100644
--- a/pages/api/teams.ts
+++ b/pages/api/teams.ts
@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "../../lib/prisma";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import slugify from "@lib/slugify";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
diff --git a/pages/api/teams/[team]/index.ts b/pages/api/teams/[team]/index.ts
index 624304233a3..33f16ef3eec 100644
--- a/pages/api/teams/[team]/index.ts
+++ b/pages/api/teams/[team]/index.ts
@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "../../../../lib/prisma";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req: req });
diff --git a/pages/api/teams/[team]/invite.ts b/pages/api/teams/[team]/invite.ts
index 3b7cdf64b47..e16526c3b3b 100644
--- a/pages/api/teams/[team]/invite.ts
+++ b/pages/api/teams/[team]/invite.ts
@@ -1,7 +1,7 @@
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "../../../../lib/prisma";
import createInvitationEmail from "../../../../lib/emails/invitation";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import { randomBytes } from "crypto";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
diff --git a/pages/api/teams/[team]/membership.ts b/pages/api/teams/[team]/membership.ts
index 8cd437e42f2..300e06de4bd 100644
--- a/pages/api/teams/[team]/membership.ts
+++ b/pages/api/teams/[team]/membership.ts
@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "../../../../lib/prisma";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req });
diff --git a/pages/api/user/[id].ts b/pages/api/user/[id].ts
index 5eed37fdee1..d1598dd7457 100644
--- a/pages/api/user/[id].ts
+++ b/pages/api/user/[id].ts
@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@lib/prisma";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req: req });
diff --git a/pages/api/user/membership.ts b/pages/api/user/membership.ts
index de48fcf504c..e307a1ae3b4 100644
--- a/pages/api/user/membership.ts
+++ b/pages/api/user/membership.ts
@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "../../../lib/prisma";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req: req });
diff --git a/pages/api/user/profile.ts b/pages/api/user/profile.ts
index fbc13c7d142..2c3f930528a 100644
--- a/pages/api/user/profile.ts
+++ b/pages/api/user/profile.ts
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import prisma, { whereAndSelect } from "@lib/prisma";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
diff --git a/pages/auth/forgot-password/index.tsx b/pages/auth/forgot-password/index.tsx
index fd2a90aa8eb..4025a5be847 100644
--- a/pages/auth/forgot-password/index.tsx
+++ b/pages/auth/forgot-password/index.tsx
@@ -1,8 +1,9 @@
import { HeadSeo } from "@components/seo/head-seo";
import Link from "next/link";
import React from "react";
-import { getCsrfToken, getSession } from "next-auth/client";
+import { getCsrfToken } from "next-auth/client";
import debounce from "lodash.debounce";
+import { getSession } from "@lib/auth";
export default function ForgotPassword({ csrfToken }) {
const [loading, setLoading] = React.useState(false);
diff --git a/pages/auth/login.tsx b/pages/auth/login.tsx
index 13152ea9929..4a79a967498 100644
--- a/pages/auth/login.tsx
+++ b/pages/auth/login.tsx
@@ -1,6 +1,7 @@
import { HeadSeo } from "@components/seo/head-seo";
import Link from "next/link";
-import { getCsrfToken, getSession } from "next-auth/client";
+import { getCsrfToken } from "next-auth/client";
+import { getSession } from "@lib/auth";
export default function Login({ csrfToken }) {
return (
diff --git a/pages/availability/index.tsx b/pages/availability/index.tsx
index bf6a8a3621b..f88c41aee9f 100644
--- a/pages/availability/index.tsx
+++ b/pages/availability/index.tsx
@@ -4,9 +4,10 @@ import Modal from "@components/Modal";
import Shell from "@components/Shell";
import { useRouter } from "next/router";
import { useRef, useState } from "react";
-import { getSession, useSession } from "next-auth/client";
+import { useSession } from "next-auth/client";
import { ClockIcon } from "@heroicons/react/outline";
import Loader from "@components/Loader";
+import { getSession } from "@lib/auth";
export default function Availability(props) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
diff --git a/pages/availability/troubleshoot.tsx b/pages/availability/troubleshoot.tsx
index 37f4ad3721e..0d215d77cb4 100644
--- a/pages/availability/troubleshoot.tsx
+++ b/pages/availability/troubleshoot.tsx
@@ -3,7 +3,7 @@ import prisma from "@lib/prisma";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import { GetServerSideProps } from "next";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import { useEffect, useState } from "react";
import Shell from "@components/Shell";
diff --git a/pages/bookings/index.tsx b/pages/bookings/index.tsx
index 3155b5c3925..282e8de07ca 100644
--- a/pages/bookings/index.tsx
+++ b/pages/bookings/index.tsx
@@ -1,5 +1,5 @@
import prisma from "@lib/prisma";
-import { getSession, useSession } from "next-auth/client";
+import { useSession } from "next-auth/client";
import Shell from "@components/Shell";
import { useRouter } from "next/router";
import dayjs from "dayjs";
@@ -9,6 +9,7 @@ import { DotsHorizontalIcon } from "@heroicons/react/solid";
import classNames from "@lib/classNames";
import { ClockIcon, XIcon } from "@heroicons/react/outline";
import Loader from "@components/Loader";
+import { getSession } from "@lib/auth";
export default function Bookings({ bookings }) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
diff --git a/pages/event-types/[type].tsx b/pages/event-types/[type].tsx
index be55cac2103..e395eba2872 100644
--- a/pages/event-types/[type].tsx
+++ b/pages/event-types/[type].tsx
@@ -7,7 +7,7 @@ import prisma from "@lib/prisma";
import { EventTypeCustomInput, EventTypeCustomInputType } from "@prisma/client";
import { LocationType } from "@lib/location";
import Shell from "@components/Shell";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import { Scheduler } from "@components/ui/Scheduler";
import { Disclosure, RadioGroup } from "@headlessui/react";
import { PhoneIcon, XIcon } from "@heroicons/react/outline";
diff --git a/pages/event-types/index.tsx b/pages/event-types/index.tsx
index a6964dc503a..b133947fe60 100644
--- a/pages/event-types/index.tsx
+++ b/pages/event-types/index.tsx
@@ -15,7 +15,7 @@ import {
import classNames from "@lib/classNames";
import showToast from "@lib/notification";
import dayjs from "dayjs";
-import { getSession, useSession } from "next-auth/client";
+import { useSession } from "next-auth/client";
import Link from "next/link";
import { useRouter } from "next/router";
import React, { Fragment, useRef } from "react";
@@ -25,6 +25,7 @@ import { GetServerSidePropsContext, InferGetServerSidePropsType } from "next";
import { useMutation } from "react-query";
import createEventType from "@lib/mutations/event-types/create-event-type";
import { ONBOARDING_INTRODUCED_AT } from "@lib/getting-started";
+import { getSession } from "@lib/auth";
const EventTypesPage = (props: InferGetServerSidePropsType<typeof getServerSideProps>) => {
const { user, types } = props;
diff --git a/pages/integrations/[integration].tsx b/pages/integrations/[integration].tsx
index 9f2586cd65b..b53de9e5312 100644
--- a/pages/integrations/[integration].tsx
+++ b/pages/integrations/[integration].tsx
@@ -3,8 +3,9 @@ import { getIntegrationName, getIntegrationType } from "@lib/integrations";
import Shell from "@components/Shell";
import { useState } from "react";
import { useRouter } from "next/router";
-import { getSession, useSession } from "next-auth/client";
+import { useSession } from "next-auth/client";
import Loader from "@components/Loader";
+import { getSession } from "@lib/auth";
export default function Integration(props) {
const router = useRouter();
diff --git a/pages/integrations/index.tsx b/pages/integrations/index.tsx
index 258b9c5a0b8..970bdf9a781 100644
--- a/pages/integrations/index.tsx
+++ b/pages/integrations/index.tsx
@@ -2,7 +2,7 @@ import Link from "next/link";
import prisma from "@lib/prisma";
import Shell from "@components/Shell";
import { useEffect, useState, useRef, useCallback } from "react";
-import { getSession, useSession } from "next-auth/client";
+import { useSession } from "next-auth/client";
import { CheckCircleIcon, ChevronRightIcon, PlusIcon, XCircleIcon } from "@heroicons/react/solid";
import { InformationCircleIcon } from "@heroicons/react/outline";
import { Dialog, DialogClose, DialogContent, DialogHeader, DialogTrigger } from "@components/Dialog";
@@ -11,6 +11,7 @@ import Loader from "@components/Loader";
import AddCalDavIntegration, {
ADD_CALDAV_INTEGRATION_FORM_TITLE,
} from "@lib/integrations/CalDav/components/AddCalDavIntegration";
+import { getSession } from "@lib/auth";
export type Integration = {
installed: boolean;
diff --git a/pages/settings/billing.tsx b/pages/settings/billing.tsx
index 63b574a4024..93048733fd9 100644
--- a/pages/settings/billing.tsx
+++ b/pages/settings/billing.tsx
@@ -1,7 +1,7 @@
import Shell from "@components/Shell";
import SettingsShell from "@components/Settings";
import prisma from "@lib/prisma";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
export default function Billing() {
return (
diff --git a/pages/settings/embed.tsx b/pages/settings/embed.tsx
index ae2b64b0182..6dfc541e1eb 100644
--- a/pages/settings/embed.tsx
+++ b/pages/settings/embed.tsx
@@ -1,8 +1,9 @@
import prisma from "@lib/prisma";
import Shell from "@components/Shell";
import SettingsShell from "@components/Settings";
-import { getSession, useSession } from "next-auth/client";
+import { useSession } from "next-auth/client";
import Loader from "@components/Loader";
+import { getSession } from "@lib/auth";
export default function Embed(props) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
diff --git a/pages/settings/password.tsx b/pages/settings/password.tsx
index 23308bcfbad..b681a473b4d 100644
--- a/pages/settings/password.tsx
+++ b/pages/settings/password.tsx
@@ -3,8 +3,9 @@ import prisma from "@lib/prisma";
import Modal from "@components/Modal";
import Shell from "@components/Shell";
import SettingsShell from "@components/Settings";
-import { getSession, useSession } from "next-auth/client";
+import { useSession } from "next-auth/client";
import Loader from "@components/Loader";
+import { getSession } from "@lib/auth";
export default function Settings() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
diff --git a/pages/settings/profile.tsx b/pages/settings/profile.tsx
index 1e67075f652..78f0e2415f1 100644
--- a/pages/settings/profile.tsx
+++ b/pages/settings/profile.tsx
@@ -5,7 +5,7 @@ import Modal from "@components/Modal";
import Shell from "@components/Shell";
import SettingsShell from "@components/Settings";
import Avatar from "@components/Avatar";
-import { getSession } from "next-auth/client";
+import { getSession } from "@lib/auth";
import Select from "react-select";
import TimezoneSelect from "react-timezone-select";
import { UsernameInput } from "@components/ui/UsernameInput";
diff --git a/pages/settings/teams.tsx b/pages/settings/teams.tsx
index 837041ec4c4..ce807e7afae 100644
--- a/pages/settings/teams.tsx
+++ b/pages/settings/teams.tsx
@@ -3,11 +3,12 @@ import Shell from "@components/Shell";
import SettingsShell from "@components/Settings";
import { useEffect, useState } from "react";
import type { Session } from "next-auth";
-import { getSession, useSession } from "next-auth/client";
+import { useSession } from "next-auth/client";
import { UsersIcon } from "@heroicons/react/outline";
import TeamList from "@components/team/TeamList";
import TeamListItem from "@components/team/TeamListItem";
import Loader from "@components/Loader";
+import { getSession } from "@lib/auth";
export default function Teams() {
const [, loading] = useSession();