From 064a55c754e02da54b13c47028b233b265327518 Mon Sep 17 00:00:00 2001 From: stuppie Date: Wed, 23 Sep 2026 13:42:03 -0600 Subject: upon login: create_paypal_cashout_method_if_not_exists using user's ip. Upon cashout request: send_cashout_confirmation_email using cashout method info looked up --- jb/views/utils.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'jb/views/utils.py') diff --git a/jb/views/utils.py b/jb/views/utils.py index 0d08e9b..a133263 100644 --- a/jb/views/utils.py +++ b/jb/views/utils.py @@ -2,17 +2,11 @@ from fastapi import Request def get_client_ip(request: Request) -> str: - """ - Using a testclient, the ip returned is 'testclient'. If so, instead, grab - the ip from the headers - """ - ip = request.headers.get("X-Forwarded-For") - if not ip: - ip = request.client.host # type: ignore - elif ip == "testclient" or ip.startswith("10."): - forwarded = request.headers.get("X-Forwarded-For") - ip = ( - forwarded.split(",")[0].strip() if forwarded else request.client.host # type: ignore - ) + forwarded = request.headers.get("X-Forwarded-For") + if forwarded: + return forwarded.split(",", 1)[0].strip() - return ip + if request.client is None: + raise ValueError("Client IP is unavailable") + + return request.client.host -- cgit v1.2.3