Skip to content

Commit

Permalink
fix(web): email callback link checking
Browse files Browse the repository at this point in the history
  • Loading branch information
cstrnt committed Feb 28, 2025
1 parent 8e26436 commit 1baa64f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 47 deletions.
15 changes: 14 additions & 1 deletion apps/web/src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { env } from "../../../env/server.mjs";
import { prisma } from "../../../server/db/client";
import { ProjectService } from "../../../server/services/ProjectService";

import type { NextApiRequest, NextApiResponse } from "next";

export const authOptions: NextAuthOptions = {
pages: {
signIn: "/login",
Expand Down Expand Up @@ -109,4 +111,15 @@ export const authOptions: NextAuthOptions = {
],
};

export default NextAuth(authOptions);
export default (req: NextApiRequest, res: NextApiResponse) => {
if (
req.url &&
new URL(req.url, "https://tryabby.com").pathname ===
"/api/auth/callback/email" &&
req.method !== "GET"
) {
console.log("Suspicous request to /api/auth/callback/email", req.method);
return res.status(200).end();
}
return NextAuth(authOptions)(req, res);
};
2 changes: 1 addition & 1 deletion apps/web/src/server/services/EventService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export abstract class EventService {
RequestCache.get(projectId),
]);

if (!project) throw new Error("Project not found");
if (!project) throw new Error(`Project not found: ${projectId}`);

const plan = Object.keys(PLANS).find(
(plan) => PLANS[plan as PlanName] === project.stripePriceId
Expand Down
Loading

0 comments on commit 1baa64f

Please sign in to comment.