AWS cognito user pools, custom message lambda

2019-06-28 07:54发布

Good day to everyone.

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).

My code is:

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());
    }
}

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 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 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.

1条回答
该账号已被封号
2楼-- · 2019-06-28 08:25

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

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.

查看更多
登录 后发表回答