From 3f23e186ba7be24dee4d0c52dbb8fc2d5001c2b6 Mon Sep 17 00:00:00 2001 From: khushal Date: Fri, 21 Feb 2025 11:13:31 +0530 Subject: [PATCH] (20250221) Session token handling to avoid exception in timed OTP APIs. --- api/blueprints/common/otp/timed_otp.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/api/blueprints/common/otp/timed_otp.py b/api/blueprints/common/otp/timed_otp.py index 5c7e6d0..0421296 100644 --- a/api/blueprints/common/otp/timed_otp.py +++ b/api/blueprints/common/otp/timed_otp.py @@ -163,14 +163,11 @@ async def generate_otp( # Either the session must be valid, or # the IP address requesting the service must be whitelisted: - if ( - kwargs.get("session_info") is None and - inbound_headers["Remote-IP"] not in current_app.whitelisted_ips - ): + if kwargs.get("session_info") is None: return ResponseModel( status_code = StatusCodes.FAILED, http_code = HttpCodes.UNAUTHORIZED, - message = "Invalid session and/or bad IP addr." + message = "Invalid session." ) # Get the user's info: @@ -304,14 +301,11 @@ async def verify_otp( # Either the session must be valid, or # the IP address requesting the service must be whitelisted: - if ( - kwargs.get("session_info") is None and - inbound_headers["Remote-IP"] not in current_app.whitelisted_ips - ): + if kwargs.get("session_info") is None: return ResponseModel( status_code = StatusCodes.FAILED, http_code = HttpCodes.UNAUTHORIZED, - message = "Invalid session and/or bad IP addr." + message = "Invalid session." ) # Get the user's info: