diff options
| author | stuppie | 2026-09-23 13:42:03 -0600 |
|---|---|---|
| committer | stuppie | 2026-09-23 13:42:03 -0600 |
| commit | 064a55c754e02da54b13c47028b233b265327518 (patch) | |
| tree | e8e2eef6a138c750640dab6b2239c3d8a6eb4191 /jb/views/utils.py | |
| parent | b1af1375578e41a240a4eedff73209e212a31051 (diff) | |
| download | amt-jb-064a55c754e02da54b13c47028b233b265327518.tar.gz amt-jb-064a55c754e02da54b13c47028b233b265327518.zip | |
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
Diffstat (limited to 'jb/views/utils.py')
| -rw-r--r-- | jb/views/utils.py | 20 |
1 files changed, 7 insertions, 13 deletions
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 |
