Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

♻️ Move auth (#1422)

Luke Vella6009a8edaebb
diff --git a/apps/web/src/utils/auth.ts b/apps/web/src/auth.ts
similarity index 98%
rename from apps/web/src/utils/auth.ts
rename to apps/web/src/auth.ts
index aad41a650..d3ad42a25 100644
--- a/apps/web/src/utils/auth.ts
+++ b/apps/web/src/auth.ts
@@ -15,11 +15,11 @@ import GoogleProvider from "next-auth/providers/google";
import { Provider } from "next-auth/providers/index";
import { posthog } from "@/app/posthog";
+import { CustomPrismaAdapter } from "@/auth/custom-prisma-adapter";
+import { mergeGuestsIntoUser } from "@/auth/merge-user";
import { env } from "@/env";
import type { RegistrationTokenPayload } from "@/trpc/types";
import { absoluteUrl } from "@/utils/absolute-url";
-import { CustomPrismaAdapter } from "@/utils/auth/custom-prisma-adapter";
-import { mergeGuestsIntoUser } from "@/utils/auth/merge-user";
import { getEmailClient } from "@/utils/emails";
import { getValueByPath } from "@/utils/get-value-by-path";
import { generateOtp, randomid } from "@/utils/nanoid";
diff --git a/apps/web/src/utils/auth/custom-prisma-adapter.ts b/apps/web/src/auth/custom-prisma-adapter.ts
similarity index 100%
rename from apps/web/src/utils/auth/custom-prisma-adapter.ts
rename to apps/web/src/auth/custom-prisma-adapter.ts
diff --git a/apps/web/src/utils/auth/merge-user.ts b/apps/web/src/auth/merge-user.ts
similarity index 100%
rename from apps/web/src/utils/auth/merge-user.ts
rename to apps/web/src/auth/merge-user.ts
diff --git a/apps/web/src/pages/[locale]/auth/disable-notifications.tsx b/apps/web/src/pages/[locale]/auth/disable-notifications.tsx
index dc3bc1594..6cc1a598b 100644
--- a/apps/web/src/pages/[locale]/auth/disable-notifications.tsx
+++ b/apps/web/src/pages/[locale]/auth/disable-notifications.tsx
@@ -1,8 +1,8 @@
import { prisma } from "@rallly/database";
import { GetServerSideProps } from "next";
+import { getServerSession } from "@/auth";
import type { DisableNotificationsPayload } from "@/trpc/types";
-import { getServerSession } from "@/utils/auth";
import { decryptToken } from "@/utils/session";
const Page = () => {
diff --git a/apps/web/src/pages/api/auth/[...nextauth].ts b/apps/web/src/pages/api/auth/[...nextauth].ts
index 4635d2726..09e252547 100644
--- a/apps/web/src/pages/api/auth/[...nextauth].ts
+++ b/apps/web/src/pages/api/auth/[...nextauth].ts
@@ -1,13 +1,13 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { posthogApiHandler } from "@/app/posthog";
-import { AuthApiRoute } from "@/utils/auth";
+import { AuthApiRoute } from "@/auth";
import { composeApiHandlers } from "@/utils/next";
export default async function auth(req: NextApiRequest, res: NextApiResponse) {
if (req.method === "HEAD") {
res.status(200).end();
- res.setHeader('Content-Length', '0');
+ res.setHeader("Content-Length", "0");
} else {
return composeApiHandlers(AuthApiRoute, posthogApiHandler)(req, res);
}
diff --git a/apps/web/src/pages/api/stripe/checkout.ts b/apps/web/src/pages/api/stripe/checkout.ts
index b4d1d08be..59d18b7e9 100644
--- a/apps/web/src/pages/api/stripe/checkout.ts
+++ b/apps/web/src/pages/api/stripe/checkout.ts
@@ -3,8 +3,8 @@ import { prisma } from "@rallly/database";
import { NextApiRequest, NextApiResponse } from "next";
import { z } from "zod";
+import { getServerSession } from "@/auth";
import { absoluteUrl } from "@/utils/absolute-url";
-import { getServerSession } from "@/utils/auth";
export const config = {
edge: true,
diff --git a/apps/web/src/pages/api/stripe/portal.ts b/apps/web/src/pages/api/stripe/portal.ts
index 2458847ab..32c492eac 100644
--- a/apps/web/src/pages/api/stripe/portal.ts
+++ b/apps/web/src/pages/api/stripe/portal.ts
@@ -3,8 +3,8 @@ import { prisma } from "@rallly/database";
import { NextApiRequest, NextApiResponse } from "next";
import { z } from "zod";
+import { getServerSession } from "@/auth";
import { absoluteUrl } from "@/utils/absolute-url";
-import { getServerSession } from "@/utils/auth";
const inputSchema = z.object({
session_id: z.string().optional(),
diff --git a/apps/web/src/pages/api/trpc/[trpc].ts b/apps/web/src/pages/api/trpc/[trpc].ts
index 9150fdb52..af2bf183b 100644
--- a/apps/web/src/pages/api/trpc/[trpc].ts
+++ b/apps/web/src/pages/api/trpc/[trpc].ts
@@ -3,8 +3,8 @@ import { TRPCError } from "@trpc/server";
import { createNextApiHandler } from "@trpc/server/adapters/next";
import { posthogApiHandler } from "@/app/posthog";
+import { getServerSession } from "@/auth";
import { AppRouter, appRouter } from "@/trpc/routers";
-import { getServerSession } from "@/utils/auth";
import { getEmailClient } from "@/utils/emails";
import { composeApiHandlers } from "@/utils/next";
diff --git a/apps/web/src/trpc/routers/auth.ts b/apps/web/src/trpc/routers/auth.ts
index 80e8102bf..b48fe65dc 100644
--- a/apps/web/src/trpc/routers/auth.ts
+++ b/apps/web/src/trpc/routers/auth.ts
@@ -2,7 +2,7 @@ import { prisma } from "@rallly/database";
import { z } from "zod";
import { posthog } from "@/app/posthog";
-import { isEmailBlocked } from "@/utils/auth";
+import { isEmailBlocked } from "@/auth";
import { generateOtp } from "@/utils/nanoid";
import { createToken, decryptToken } from "@/utils/session";