AWS Cognito用户池,自定义消息Lambda [英] AWS cognito user pools, custom message lambda

查看:123
本文介绍了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):

我基于

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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