mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 08:51:30 -05:00
Use sms sender or reply to email address of the Notify service in create_2fa_code depending on message type.
This commit is contained in:
@@ -214,7 +214,11 @@ def create_2fa_code(template_id, user_to_send_to, secret_code, recipient, person
|
||||
|
||||
# save the code in the VerifyCode table
|
||||
create_user_code(user_to_send_to, secret_code, template.template_type)
|
||||
|
||||
reply_to = None
|
||||
if template.template_type == SMS_TYPE:
|
||||
reply_to = template.service.get_default_sms_sender()
|
||||
elif template.template_type == EMAIL_TYPE:
|
||||
reply_to = template.service.get_default_reply_to_email_address()
|
||||
saved_notification = persist_notification(
|
||||
template_id=template.id,
|
||||
template_version=template.version,
|
||||
@@ -224,7 +228,7 @@ def create_2fa_code(template_id, user_to_send_to, secret_code, recipient, person
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
reply_to_text=template.service.get_default_sms_sender()
|
||||
reply_to_text=reply_to
|
||||
)
|
||||
# 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
|
||||
|
||||
@@ -357,6 +357,7 @@ def test_send_user_email_code(admin_request, mocker, sample_user, email_2fa_code
|
||||
_expected_status=204
|
||||
)
|
||||
noti = Notification.query.one()
|
||||
assert noti.reply_to_text == email_2fa_code_template.service.get_default_reply_to_email_address()
|
||||
assert noti.to == sample_user.email_address
|
||||
assert str(noti.template_id) == current_app.config['EMAIL_2FA_TEMPLATE_ID']
|
||||
assert noti.personalisation['name'] == 'Test User'
|
||||
|
||||
Reference in New Issue
Block a user