用于注册和忘记密码的不同电子邮件验证消息 [英] Different email verification messages for sign-up and forgot-password

查看:40
本文介绍了用于注册和忘记密码的不同电子邮件验证消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 AWS 的 Cognito 可以获得很多好处,因为大多数功能(如果不是全部)已经由 AWS 实现.但是我遇到了一种情况,我不确定如何使用 Cognito 来实现.考虑以下两种情况:

Using the AWS's Cognito one can gain a lot since most of the functionalities (if not all) are already implemented by AWS. But I've faced a situation which I'm not sure how to implement using Cognito. Consider the following two scenarios:

  • 注册:

  1. 用户通过提供电子邮件和密码进行注册
  2. 向用户发送一封带有确认码的电子邮件
  3. 用户发送用户名和确认码以完成流程

  • 忘记密码:

    1. 用户通过发送他/她的用户名请求代码
    2. 使用上一步中生成的代码向用户发送一封电子邮件
    3. 用户通过提供用户名、新密码和代码来重置密码

  • 以上陈述是根据 AWS Cognito 的实施方式量身定制的.正如您所看到的,最后两个步骤在每个场景中都需要不同的输入.现在,我的问题是为什么 AWS Cognito 对它们使用相同的电子邮件模板(在第二步中)?

    The statements above are tailored according to how AWS Cognito is implemented. And as you can see, the two final steps require different input in each of the scenarios. Now, my question is why AWS Cognito uses the same email template (in the second step) for both of them?

    AFAIK,Cognito 中只有一个模板(消息自定义"部分),无论发送电子邮件以确认用户的电子邮件所有权或用户请求密码重置代码,都会使用它.

    AFAIK, there's only one template in Cognito ("Message customizations" section) and it is used regardless of the email is sent to confirm user's email ownership or user has requested for a password reset code.

    这对我来说是个问题,因为我希望两封电子邮件的内容不同.首先,它们应该包含不同的链接.

    This is a problem for me since I want the content of the two emails to be different. For starters, they should contain different links in them.

    有没有办法在 Cognito 中发送两封不同的确认码和忘记密码的电子邮件?

    Is there a way to send two different emails for confirmation code and forgot password in Cognito?

    推荐答案

    事实证明,答案是使用 触发器 中的自定义消息.Cognito 允许您为用户池中生成的不同事件指定 lambda 函数.其中之一是自定义消息.每次将要向客户端发送电子邮件时,都会调用此 lambda 函数.使用提供给 lambda 函数的输入数据,您可以了解它是哪种场景并为该电子邮件撰写正确的内容.

    As it turned out the answer is to use Custom message from Triggers. Cognito lets you specify lambda functions for the different event generated in a user pool. One of which is Custom message. This lambda function is called each time an email is about to be sent to the client. Using the input data given to the lambda function, one can realize which scenario it is and compose the correct content for that email.

    这是文档的链接:

    https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html

    这篇关于用于注册和忘记密码的不同电子邮件验证消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆