mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
Use notify to send email verification
This commit is contained in:
@@ -28,8 +28,8 @@ from app.schemas import (
|
||||
from app.celery.tasks import (
|
||||
send_sms,
|
||||
email_reset_password,
|
||||
email_registration_verification
|
||||
)
|
||||
email_registration_verification,
|
||||
send_email)
|
||||
|
||||
from app.errors import register_errors
|
||||
|
||||
@@ -157,13 +157,26 @@ def send_user_email_verification(user_id):
|
||||
secret_code = create_secret_code()
|
||||
create_user_code(user_to_send_to, secret_code, 'email')
|
||||
|
||||
email = user_to_send_to.email_address
|
||||
verification_message = {'to': email,
|
||||
'name': user_to_send_to.name,
|
||||
'url': _create_verification_url(user_to_send_to, secret_code)}
|
||||
|
||||
email_registration_verification.apply_async([encryption.encrypt(verification_message)],
|
||||
queue='email-registration-verification')
|
||||
template = dao_get_template_by_id(current_app.config['EMAIL_VERIFY_CODE_TEMPLATE_ID'])
|
||||
message = {
|
||||
'template': template.id,
|
||||
'template_version': template.version,
|
||||
'to': user_to_send_to.email_address,
|
||||
'personalisation': {
|
||||
'user_name': user_to_send_to.name,
|
||||
'url': _create_verification_url(user_to_send_to, secret_code)
|
||||
}
|
||||
}
|
||||
email_from = '"GOV.UK Notify" <{}>'.format(
|
||||
current_app.config['VERIFY_CODE_FROM_EMAIL_ADDRESS']
|
||||
)
|
||||
send_email.apply_async((
|
||||
current_app.config['NOTIFY_SERVICE_ID'],
|
||||
str(uuid.uuid4()),
|
||||
email_from,
|
||||
encryption.encrypt(message),
|
||||
datetime.utcnow().strftime(DATETIME_FORMAT)
|
||||
), queue='email-registration-verification')
|
||||
|
||||
return jsonify({}), 204
|
||||
|
||||
|
||||
Reference in New Issue
Block a user