From be950a7322362feea8abb779feb4216c381b7c67 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 9 Jan 2024 13:09:07 -0800 Subject: [PATCH 1/3] no verification code on staging --- app/user/rest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/user/rest.py b/app/user/rest.py index 7941504ee..f5dda2a93 100644 --- a/app/user/rest.py +++ b/app/user/rest.py @@ -352,6 +352,11 @@ def create_2fa_code( ) redis_store.set(f"2facode_{saved_notification.id}", recipient, ex=1800) + stored_recipient = redis_store.get("2facode_{saved_notification.id}") + if stored_recipient: + current_app.logger.info("IN user/rest.py we saved the recipient of the 2facode to redis!") + else: + current_app.logger.info("IN user/rest.py we did NOT save the recipient of the 2facode to redis!") # Assume that we never want to observe the Notify service's research mode # setting for this notification - we still need to be able to log into the # admin even if we're doing user research using this service: From d3ca06fec21cb8edddd9f361741a93e68d3c92bf Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 9 Jan 2024 13:36:57 -0800 Subject: [PATCH 2/3] fix --- app/delivery/send_to_providers.py | 5 ++++- app/user/rest.py | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index 79bf77fd2..f21e3928e 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -77,7 +77,10 @@ def send_sms_to_provider(notification): notification.job_row_number, ) except BaseException: - my_phone = redis_store.get(f"2facode_{notification.id}") + key = f"2facode{notification.id}" + key = key.replace("-", "") + key = key.replace(" ", "") + my_phone = redis_store.get(key) if my_phone: my_phone = my_phone.decode("utf-8") if my_phone is None: diff --git a/app/user/rest.py b/app/user/rest.py index f5dda2a93..a63292cc0 100644 --- a/app/user/rest.py +++ b/app/user/rest.py @@ -351,8 +351,12 @@ def create_2fa_code( reply_to_text=reply_to, ) - redis_store.set(f"2facode_{saved_notification.id}", recipient, ex=1800) - stored_recipient = redis_store.get("2facode_{saved_notification.id}") + key = f"2facode{saved_notification.id}" + key = key.replace("-", "") + key = key.replace(" ", "") + recipient = str(recipient) + redis_store.set(key, recipient) + stored_recipient = redis_store.get(key) if stored_recipient: current_app.logger.info("IN user/rest.py we saved the recipient of the 2facode to redis!") else: From 5366992d1a7d06f504a72c883deb5c2dbbb6584c Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 9 Jan 2024 14:01:03 -0800 Subject: [PATCH 3/3] format --- app/delivery/send_to_providers.py | 5 ++--- app/user/rest.py | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index f21e3928e..be97a83c6 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -77,10 +77,9 @@ def send_sms_to_provider(notification): notification.job_row_number, ) except BaseException: - key = f"2facode{notification.id}" - key = key.replace("-", "") - key = key.replace(" ", "") + key = f"2facode-{notification.id}".replace(" ", "") my_phone = redis_store.get(key) + if my_phone: my_phone = my_phone.decode("utf-8") if my_phone is None: diff --git a/app/user/rest.py b/app/user/rest.py index a63292cc0..d9b23a677 100644 --- a/app/user/rest.py +++ b/app/user/rest.py @@ -351,9 +351,7 @@ def create_2fa_code( reply_to_text=reply_to, ) - key = f"2facode{saved_notification.id}" - key = key.replace("-", "") - key = key.replace(" ", "") + key = f"2facode-{saved_notification.id}".replace(" ", "") recipient = str(recipient) redis_store.set(key, recipient) stored_recipient = redis_store.get(key)