Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add to allow list from blocked email e2cf

Marc Seitze868d0740b1e
diff --git a/app/(auth)/login/page-client.tsx b/app/(auth)/login/page-client.tsx
index 689e9032..647f0b5e 100644
--- a/app/(auth)/login/page-client.tsx
+++ b/app/(auth)/login/page-client.tsx
@@ -1,14 +1,13 @@
"use client";
import Link from "next/link";
-import { useParams, useRouter, useSearchParams } from "next/navigation";
+import { useRouter, useSearchParams } from "next/navigation";
import { useState } from "react";
-import { AlertCircle } from "lucide-react";
-
import { SSOLogin } from "@/ee/features/security/sso";
import { signInWithPasskey } from "@teamhanko/passkeys-next-auth-provider/client";
+import { AlertCircle } from "lucide-react";
import { signIn } from "next-auth/react";
import { toast } from "sonner";
import { z } from "zod";
@@ -25,9 +24,9 @@ import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
export default function Login() {
- const { next } = useParams as { next?: string };
const router = useRouter();
const searchParams = useSearchParams();
+ const next = searchParams?.get("next") ?? undefined;
const authError = searchParams?.get("error");
const isSSORequired = authError === "require-saml-sso";
@@ -260,7 +259,7 @@ export default function Login() {
<div className="flex w-full max-w-xl flex-col items-center">
<div className="mb-6 w-full max-w-md">
<img
- className="h-auto w-full rounded-[4px] object-cover "
+ className="h-auto w-full rounded-[4px] object-cover"
src="/_static/testimonials/backtrace.jpeg"
alt="Backtrace Capital"
/>
diff --git a/lib/middleware/app.ts b/lib/middleware/app.ts
index e1473a0e..b5b3ec98 100644
--- a/lib/middleware/app.ts
+++ b/lib/middleware/app.ts
@@ -66,8 +66,12 @@ export default async function AppMiddleware(req: NextRequest) {
const loginUrl = new URL(LOGIN_PATH, req.url);
// Append "next" parameter only if not navigating to the root
if (path !== "/") {
- const nextPath =
- path === "/auth/confirm-email-change" ? `${path}${url.search}` : path;
+ // Some destinations carry meaningful query params (e.g. the allow-list
+ // action link identifies the link and visitor email). Preserve the full
+ // search string for those so it survives the login round-trip.
+ const preserveSearch =
+ path === "/auth/confirm-email-change" || path.startsWith("/access/");
+ const nextPath = preserveSearch ? `${path}${url.search}` : path;
loginUrl.searchParams.set("next", nextPath);
}