revamp how authentication code is displayed as per Steven

This commit is contained in:
Kenneth Kehl
2023-08-30 09:29:08 -07:00
609 changed files with 35179 additions and 24825 deletions

View File

@@ -24,7 +24,7 @@ class AwsSnsClient(SmsClient):
aws_access_key_id=cloud_config.sns_access_key,
aws_secret_access_key=cloud_config.sns_secret_key,
config=AWS_CLIENT_CONFIG,
endpoint_url=os.getenv("LOCALSTACK_ENDPOINT_URL")
endpoint_url=os.getenv("LOCALSTACK_ENDPOINT_URL"),
)
else:
self._client = client(
@@ -34,13 +34,14 @@ class AwsSnsClient(SmsClient):
aws_secret_access_key=cloud_config.sns_secret_key,
config=AWS_CLIENT_CONFIG,
)
super(SmsClient, self).__init__(*args, **kwargs)
self.current_app = current_app
self._valid_sender_regex = re.compile(r"^\+?\d{5,14}$")
@property
def name(self):
return 'sns'
return "sns"
def get_name(self):
return self.name
@@ -53,7 +54,9 @@ class AwsSnsClient(SmsClient):
for match in phonenumbers.PhoneNumberMatcher(to, "US"):
matched = True
to = phonenumbers.format_number(match.number, phonenumbers.PhoneNumberFormat.E164)
to = phonenumbers.format_number(
match.number, phonenumbers.PhoneNumberFormat.E164
)
# See documentation
# https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html#sms_publish_sdk
@@ -77,14 +80,18 @@ class AwsSnsClient(SmsClient):
try:
start_time = monotonic()
response = self._client.publish(PhoneNumber=to, Message=content, MessageAttributes=attributes)
response = self._client.publish(
PhoneNumber=to, Message=content, MessageAttributes=attributes
)
except botocore.exceptions.ClientError as e:
raise str(e)
except Exception as e:
raise str(e)
finally:
elapsed_time = monotonic() - start_time
self.current_app.logger.info("AWS SNS request finished in {}".format(elapsed_time))
self.current_app.logger.info(
"AWS SNS request finished in {}".format(elapsed_time)
)
return response["MessageId"]
if not matched: