Skip to content

Commit 5bd084d

Browse files
committed
Add an env var feature flags for login rate limiting
1 parent 97568dc commit 5bd084d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

apps/webapp/app/env.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const EnvironmentSchema = z
5959
ADMIN_EMAILS: z.string().refine(isValidRegex, "ADMIN_EMAILS must be a valid regex.").optional(),
6060
REMIX_APP_PORT: z.string().optional(),
6161
LOGIN_ORIGIN: z.string().default("http://localhost:3030"),
62+
LOGIN_RATE_LIMITS_ENABLED: z.enum(["0", "1"]).default("1"),
6263
APP_ORIGIN: z.string().default("http://localhost:3030"),
6364
API_ORIGIN: z.string().optional(),
6465
STREAM_ORIGIN: z.string().optional(),

apps/webapp/app/routes/login.magic/route.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
checkMagicLinkIpRateLimit,
3030
} from "~/services/magicLinkRateLimiter.server";
3131
import { logger, tryCatch } from "@trigger.dev/core/v3";
32+
import { env } from "~/env.server";
3233

3334
export const meta: MetaFunction = ({ matches }) => {
3435
const parentMeta = matches
@@ -96,6 +97,13 @@ export async function action({ request }: ActionFunctionArgs) {
9697

9798
switch (data.action) {
9899
case "send": {
100+
if (env.LOGIN_RATE_LIMITS_ENABLED !== "1") {
101+
return authenticator.authenticate("email-link", request, {
102+
successRedirect: "/login/magic",
103+
failureRedirect: "/login/magic",
104+
});
105+
}
106+
99107
const { email } = data;
100108
const clientIp = request.headers.get("x-forwarded-for");
101109

0 commit comments

Comments
 (0)