2016-11-15 3 views
0

Amazon Cognito отправляет электронное письмо с подтверждением по запросам забытых паролей. Как обновить это письмо для проверки с помощью персонализированных параметров, чтобы он содержал следующие параметры: (имя пользователя/адрес электронной почты).Как вставить персонализированный параметр в адрес электронной почты Amazon Cognito

ответ

1

Вы можете использовать функцию лямбда для пользовательского сообщения, похожего на приведенное ниже. Код для лямбда-функции можно ввести в лямбда-консоль и настроить через панель «Триггеры» в пуле пользователей.

Вы должны проверить event.triggerSource, чтобы убедиться, что это событие forgotPassword, и вы получите доступ к электронной почте и имя пользователя, как event.request.userAttributes.email и event.userName

exports.handler = function(event, context) { 
    // 
    if(event.userPoolId === "theSpecialUserPool") { 
     // Identify why was this function invoked 
     if(event.triggerSource === "CustomMessage_ForgotPassword") { 
      // Ensure that your message contains event.request.codeParameter. This is the placeholder for code that will be sent 
      event.response.smsMessage = "You requested to reset your password " + event.request.codeParameter; 
      event.response.emailSubject = "You requested to reset your password " + event.request.userAttributes.email + " " + event.request.userName; 
      event.response.emailMessage = "Thank you for signing up. " + event.request.codeParameter + " is your verification code " + event.request.userAttributes.email + " " + event.request.userName; 
     } 
     // Create custom message for other events 
    } 
    // Customize messages for other user pools 

    // 

    // Return result to Cognito 
    context.done(null, event); 
};