mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-08 08:28:24 -04:00
add new template to config
and rename existing new user email verification template for clarity
This commit is contained in:
@@ -125,7 +125,8 @@ class Config(object):
|
|||||||
NOTIFY_USER_ID = '6af522d0-2915-4e52-83a3-3690455a5fe6'
|
NOTIFY_USER_ID = '6af522d0-2915-4e52-83a3-3690455a5fe6'
|
||||||
INVITATION_EMAIL_TEMPLATE_ID = '4f46df42-f795-4cc4-83bb-65ca312f49cc'
|
INVITATION_EMAIL_TEMPLATE_ID = '4f46df42-f795-4cc4-83bb-65ca312f49cc'
|
||||||
SMS_CODE_TEMPLATE_ID = '36fb0730-6259-4da1-8a80-c8de22ad4246'
|
SMS_CODE_TEMPLATE_ID = '36fb0730-6259-4da1-8a80-c8de22ad4246'
|
||||||
EMAIL_VERIFY_CODE_TEMPLATE_ID = 'ece42649-22a8-4d06-b87f-d52d5d3f0a27'
|
EMAIL_2FA_TEMPLATE_ID = '299726d2-dba6-42b8-8209-30e1d66ea164'
|
||||||
|
NEW_USER_EMAIL_VERIFICATION_TEMPLATE_ID = 'ece42649-22a8-4d06-b87f-d52d5d3f0a27'
|
||||||
PASSWORD_RESET_TEMPLATE_ID = '474e9242-823b-4f99-813d-ed392e7f1201'
|
PASSWORD_RESET_TEMPLATE_ID = '474e9242-823b-4f99-813d-ed392e7f1201'
|
||||||
ALREADY_REGISTERED_EMAIL_TEMPLATE_ID = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'
|
ALREADY_REGISTERED_EMAIL_TEMPLATE_ID = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'
|
||||||
CHANGE_EMAIL_CONFIRMATION_TEMPLATE_ID = 'eb4d9930-87ab-4aef-9bce-786762687884'
|
CHANGE_EMAIL_CONFIRMATION_TEMPLATE_ID = 'eb4d9930-87ab-4aef-9bce-786762687884'
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ def send_user_email_code(user_id):
|
|||||||
|
|
||||||
create_user_code(user_to_send_to, uuid.uuid4(), EMAIL_TYPE)
|
create_user_code(user_to_send_to, uuid.uuid4(), EMAIL_TYPE)
|
||||||
|
|
||||||
template = dao_get_template_by_id(current_app.config['EMAIL_CODE_TEMPLATE_ID'])
|
template = dao_get_template_by_id(current_app.config['EMAIL_2FA_TEMPLATE_ID'])
|
||||||
personalisation = {'url': _create_2fa_url(user_to_send_to)},
|
personalisation = {'url': _create_2fa_url(user_to_send_to)},
|
||||||
|
|
||||||
create_2fa_code(template, user_to_send_to.email_address, personalisation)
|
create_2fa_code(template, user_to_send_to.email_address, personalisation)
|
||||||
@@ -238,13 +238,13 @@ def send_user_confirm_new_email(user_id):
|
|||||||
|
|
||||||
|
|
||||||
@user_blueprint.route('/<uuid:user_id>/email-verification', methods=['POST'])
|
@user_blueprint.route('/<uuid:user_id>/email-verification', methods=['POST'])
|
||||||
def send_user_email_verification(user_id):
|
def send_new_user_email_verification(user_id):
|
||||||
# when registering, we verify all users' email addresses using this function
|
# when registering, we verify all users' email addresses using this function
|
||||||
user_to_send_to = get_user_by_id(user_id=user_id)
|
user_to_send_to = get_user_by_id(user_id=user_id)
|
||||||
secret_code = create_secret_code()
|
secret_code = create_secret_code()
|
||||||
create_user_code(user_to_send_to, secret_code, 'email')
|
create_user_code(user_to_send_to, secret_code, 'email')
|
||||||
|
|
||||||
template = dao_get_template_by_id(current_app.config['EMAIL_VERIFY_CODE_TEMPLATE_ID'])
|
template = dao_get_template_by_id(current_app.config['NEW_USER_EMAIL_VERIFICATION_TEMPLATE_ID'])
|
||||||
service = Service.query.get(current_app.config['NOTIFY_SERVICE_ID'])
|
service = Service.query.get(current_app.config['NOTIFY_SERVICE_ID'])
|
||||||
|
|
||||||
saved_notification = persist_notification(
|
saved_notification = persist_notification(
|
||||||
|
|||||||
@@ -871,7 +871,7 @@ def email_verification_template(notify_db,
|
|||||||
return create_custom_template(
|
return create_custom_template(
|
||||||
service=service,
|
service=service,
|
||||||
user=user,
|
user=user,
|
||||||
template_config_name='EMAIL_VERIFY_CODE_TEMPLATE_ID',
|
template_config_name='NEW_USER_EMAIL_VERIFICATION_TEMPLATE_ID',
|
||||||
content='((user_name)) use ((url)) to complete registration',
|
content='((user_name)) use ((url)) to complete registration',
|
||||||
template_type='email'
|
template_type='email'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -261,14 +261,14 @@ def test_send_sms_code_returns_204_when_too_many_codes_already_created(client, s
|
|||||||
assert VerifyCode.query.count() == 10
|
assert VerifyCode.query.count() == 10
|
||||||
|
|
||||||
|
|
||||||
def test_send_user_email_verification(client,
|
def test_send_new_user_email_verification(client,
|
||||||
sample_user,
|
sample_user,
|
||||||
mocker,
|
mocker,
|
||||||
email_verification_template):
|
email_verification_template):
|
||||||
mocked = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
mocked = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
||||||
auth_header = create_authorization_header()
|
auth_header = create_authorization_header()
|
||||||
resp = client.post(
|
resp = client.post(
|
||||||
url_for('user.send_user_email_verification', user_id=str(sample_user.id)),
|
url_for('user.send_new_user_email_verification', user_id=str(sample_user.id)),
|
||||||
data=json.dumps({}),
|
data=json.dumps({}),
|
||||||
headers=[('Content-Type', 'application/json'), auth_header])
|
headers=[('Content-Type', 'application/json'), auth_header])
|
||||||
assert resp.status_code == 204
|
assert resp.status_code == 204
|
||||||
@@ -284,7 +284,7 @@ def test_send_email_verification_returns_404_for_bad_input_data(client, notify_d
|
|||||||
uuid_ = uuid.uuid4()
|
uuid_ = uuid.uuid4()
|
||||||
auth_header = create_authorization_header()
|
auth_header = create_authorization_header()
|
||||||
resp = client.post(
|
resp = client.post(
|
||||||
url_for('user.send_user_email_verification', user_id=uuid_),
|
url_for('user.send_new_user_email_verification', user_id=uuid_),
|
||||||
data=json.dumps({}),
|
data=json.dumps({}),
|
||||||
headers=[('Content-Type', 'application/json'), auth_header])
|
headers=[('Content-Type', 'application/json'), auth_header])
|
||||||
assert resp.status_code == 404
|
assert resp.status_code == 404
|
||||||
|
|||||||
Reference in New Issue
Block a user