Use GOV.UK Notify service to send the forgot password email link using the template to create the message.

This commit is contained in:
Rebecca Law
2016-06-16 10:43:41 +01:00
parent 92fdba7010
commit d6e920fa89
2 changed files with 25 additions and 9 deletions

View File

@@ -217,11 +217,20 @@ def send_user_reset_password():
user_to_send_to = get_user_by_email(email['email'])
reset_password_message = {'to': user_to_send_to.email_address,
'name': user_to_send_to.name,
'reset_password_url': _create_reset_password_url(user_to_send_to.email_address)}
email_reset_password.apply_async([encryption.encrypt(reset_password_message)], queue='email-reset-password')
template = dao_get_template_by_id(current_app.config['PASSWORD_RESET_TEMPLATE_ID'])
message = {
'template': str(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, _create_reset_password_url(user_to_send_to.email_address))
}
}
send_email.apply_async([current_app.config['NOTIFY_SERVICE_ID'],
str(uuid.uuid4()),
encryption.encrypt(message),
datetime.utcnow().strftime(DATETIME_FORMAT)], queue='email-reset-password')
return jsonify({}), 204