File tree Expand file tree Collapse file tree 3 files changed +16
-14
lines changed
Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -9,16 +9,14 @@ import {
99 setImpersonationId ,
1010} from "~/services/impersonation.server" ;
1111import { requireUser } from "~/services/session.server" ;
12-
13- function extractClientIp ( xff : string | null ) : string | null {
14- if ( ! xff ) return null ;
15- const parts = xff . split ( "," ) . map ( ( p ) => p . trim ( ) ) ;
16- return parts [ parts . length - 1 ] ; // ALB appends the real client IP
17- }
12+ import { extractClientIp } from "~/utils/extractClientIp.server" ;
1813
1914const pageSize = 20 ;
2015
21- export async function adminGetUsers ( userId : string , { page, search } : SearchParams ) {
16+ export async function adminGetUsers (
17+ userId : string ,
18+ { page, search } : SearchParams ,
19+ ) {
2220 page = page || 1 ;
2321
2422 search = search ? decodeURIComponent ( search ) : undefined ;
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import {
3030} from "~/services/magicLinkRateLimiter.server" ;
3131import { logger , tryCatch } from "@trigger.dev/core/v3" ;
3232import { env } from "~/env.server" ;
33+ import { extractClientIp } from "~/utils/extractClientIp.server" ;
3334
3435export const meta : MetaFunction = ( { matches } ) => {
3536 const parentMeta = matches
@@ -169,13 +170,6 @@ export async function action({ request }: ActionFunctionArgs) {
169170 }
170171}
171172
172- const extractClientIp = ( xff : string | null ) => {
173- if ( ! xff ) return null ;
174-
175- const parts = xff . split ( "," ) . map ( ( p ) => p . trim ( ) ) ;
176- return parts [ parts . length - 1 ] ; // take last item, ALB appends the real client IP by default
177- } ;
178-
179173export default function LoginMagicLinkPage ( ) {
180174 const { magicLinkSent, magicLinkError } = useTypedLoaderData < typeof loader > ( ) ;
181175 const navigate = useNavigation ( ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Extracts the client IP address from the X-Forwarded-For header.
3+ * Takes the last item in the header since ALB appends the real client IP by default.
4+ */
5+ export function extractClientIp ( xff : string | null ) : string | null {
6+ if ( ! xff ) return null ;
7+
8+ const parts = xff . split ( "," ) . map ( ( p ) => p . trim ( ) ) ;
9+ return parts [ parts . length - 1 ] ; // take last item, ALB appends the real client IP by default
10+ }
You can’t perform that action at this time.
0 commit comments