AWS Cognito用户池,自定义消息Lambda

编程入门 行业动态 更新时间:2024-10-27 10:18:54
本文介绍了AWS Cognito用户池,自定义消息Lambda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好.

我对在lambda函数内部作为触发器创建的AWS cognito用户池自定义消息有疑问(自定义消息lambda).内含验证链接的消息.特别是,我将消息主题设置为自定义主题"(电子邮件具有此主题),并将消息主体设置为改为使用此{## Custom link ##}"(消息不会出现在主体中,而是使用用户池Web界面中的一个).

I have a problem with AWS cognito user pools custom message which is created inside lambda function as a trigger (custom message lambda). Message with verification link inside. In particular I'm setting message subject to "Custom subject" (and email has this subject), and message body to "Use this {##Custom link##} instead" (and the message is not appear in the body, but the one from user pools web interface is used).

我的代码是:

public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { JsonNode json = parseJsonFromStream(input); ObjectNode jsonWithResponse = (ObjectNode) json; jsonWithResponse.with("response").put("emailMessage", "Use this {##Custom link##} instead"); jsonWithResponse.with("response").put("emailSubject", "Custom subject"); try (Writer w = new OutputStreamWriter(output, "UTF-8")) { w.write(jsonWithResponse.toString()); } }

我曾尝试设置{####}而不是{## Link text ##},但仍然相同.我几乎可以肯定它在一段时间前就可以使用了(我不记得自己做了什么更改).有谁知道我应该去哪里看(挖).由于我在此上花费了太多时间,并且没有遗漏(希望如此)小的东西,或者它们有一些更改/问题.

I had tried to set even {####} instead {##Link text##} and still same. I'm almost sure it worked some time ago (and I don't remember I changed anything). Does anyone has any idea where should I take a look (dig). As I spent too much time on that and neither missing something (hopefully) small or they have some changes/issues.

P.S. lambda测试成功. Lambda输出看起来不错(我在这里消除了记录器).

P.S. lambda test success. Lambda output looks fine (I eliminate logger here).

更新:(带响应的记录器输出)

Upd: (logger output with response)

OUTPUT JSON is { "version": "1", "region": "eu-west-1", "userPoolId": "****", "userName": "*****", "callerContext": { "awsSdkVersion": "aws-sdk-android-2.6.7", "clientId": "****" }, "triggerSource": "CustomMessage_SignUp", "request": { "userAttributes": { "sub": "****", "email_verified": "false", "cognito:user_status": "UNCONFIRMED", "nickname": "Yaroslav", "email": "****" }, "codeParameter": "{####}", "usernameParameter": null }, "response": { "emailMessage": "Use this {##Custom link##} instead", "emailSubject": "Custom subject" } }

Upd2(JS触发器):

Upd2 (JS trigger):

我基于示例,当用户需要确认代码时,该方法适用于自定义电子邮件,但不适用于确认链接.再次,我尝试使用{## link ##}作为链接.

I added code on js (new trigger for custom email) based on example and that works for custom email when user wants confirmation code, but that doesn't work for confirmation link. Again, I tried {##link##} for the link.

推荐答案

所以我最终得到的是使用代码确认.在这种情况下,自定义电子邮件将按预期工作.

So what I ended up with is to use code confirmation. In this case custom email works as expected.

为了防止用户在应用程序中输入密码,我发送了带有自定义链接的电子邮件,其中包含代码参数.自定义链接指向API网关,该API网关具有相应的lambda来处理所有内容并完成用户注册.

To prevent the user from typing the password into the app, I sent email with custom link, which include the code parametr. Custom link pointed to API Gateway which had corresponding lambda to handle everything and finish the user registration.

更多推荐

AWS Cognito用户池,自定义消息Lambda

本文发布于:2023-11-16 04:42:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1601089.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   消息   用户   AWS   Cognito

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!