diff --git a/apps/cic-ussd/.config/app.ini b/apps/cic-ussd/.config/app.ini index 3efaaabc..e4336201 100644 --- a/apps/cic-ussd/.config/app.ini +++ b/apps/cic-ussd/.config/app.ini @@ -6,6 +6,9 @@ MAX_BODY_LENGTH=1024 PASSWORD_PEPPER=QYbzKff6NhiQzY3ygl2BkiKOpER8RE/Upqs/5aZWW+I= SERVICE_CODE=*483*46# +[phone_number] +REGION=KE + [ussd] MENU_FILE=/usr/src/data/ussd_menu.json diff --git a/apps/cic-ussd/cic_ussd/runnable/server.py b/apps/cic-ussd/cic_ussd/runnable/server.py index 36942c0f..ed839ef4 100644 --- a/apps/cic-ussd/cic_ussd/runnable/server.py +++ b/apps/cic-ussd/cic_ussd/runnable/server.py @@ -27,6 +27,7 @@ from cic_ussd.metadata.user import UserMetadata from cic_ussd.operations import (define_response_with_content, process_menu_interaction_requests, define_multilingual_responses) +from cic_ussd.phone_number import process_phone_number from cic_ussd.redis import InMemoryStore from cic_ussd.requests import (get_request_endpoint, get_request_method, @@ -151,6 +152,10 @@ def application(env, start_response): external_session_id = post_data.get('sessionId') user_input = post_data.get('text') + # add validation for phone number + if phone_number: + phone_number = process_phone_number(phone_number=phone_number, region=config.get('PHONE_NUMBER_REGION')) + # validate ip address if not check_ip(config=config, env=env): start_response('403 Sneaky, sneaky', errors_headers)