Dmi*_*nko 12 javascript amazon-web-services amazon-cognito
我正在使用适用于JavaScript的Amazon Cognito身份SDK。
我创建了新池而不验证电子邮件和phone_number。
默认情况下,不会在Cognito用户池中确认用户,因此我需要手动执行此操作。
如何在不验证电子邮件或电话的情况下在Cognito用户池中确认用户?
Ula*_*Ula 18
我希望这会帮助其他人。
为此,您可以添加以下Lambda函数:
exports.handler = (event, context, callback) => {
event.response.autoConfirmUser = true;
event.response.autoVerifyEmail = true; // this is NOT needed if e-mail is not in attributeList
event.response.autoVerifyPhone = true; // this is NOT needed if phone # is not in attributeList
context.done(null, event);
};
Run Code Online (Sandbox Code Playgroud)
然后导航至AWS Cognito的常规设置>>触发器,并将此Lambda函数添加到“预注册”中-单击下拉列表,然后选择带有上述代码的Lambda函数。
如果仅使用“ preferred_username”(如果未使用电子邮件或电话号码),那么将event.response.autoConfirmUser设置为true就足够了。
boy*_*boy 10
我认为接受的答案是有问题的。OP的问题是如何在不验证电子邮件的情况下确认用户。但该解决方案将验证用户的电子邮件。
如果您想使用未经验证的电子邮件(或电话)确认用户,您可以使用AdminConfirmSignUpCommand。根据官方文档,这是在不让用户这样做的情况下确认用户的预期方法:
与 不同的是ConfirmSignUpCommand,AdminConfirmSignUpCommand不需要代码。您可以在 API 中注册后实施此命令,也可以将其作为自定义消息触发器(在发送电子邮件时有效确认用户)。
现在,用户可以登录,但仍必须确认电子邮件。
实际上,AWS最近在注册前的 lambda中还增加了验证电子邮件和验证电话号码的功能。您基本上需要在lambda中设置autoVerifyEmail和autoVerifyPhone,它们将得到验证。官方文档中有更多信息。
"response": {
"autoConfirmUser": boolean
"autoVerifyEmail": boolean
"autoVerifyPhone": boolean
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4248 次 |
| 最近记录: |