Lambda AWS PreSignUp 响应的正确格式是什么
Which is the correct format for Lambda AWS PreSignUp Response
我正在做一个 VUE+Amplify 项目,它快完成了,但 cognito 不提供邮件重复检查,所以我必须手动进行,因为我们知道 AWS 有一些触发器我正在使用 PreSignUp调用 Lambda 函数,我的代码是:
var AWS = require("aws-sdk");
const cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
exports.handler = function(event, context, callback) {
var params = {
UserPoolId: "us-east-1_xxxXXXxXX",
AttributesToGet: ["email"]
};
cognitoidentityserviceprovider.listUsers(params, (err, data) => {
if (err) {
console.log(err, err.stack);
callback(err) // here is the error return
} else {
data.Users.forEach(function(usuario) {
if(usuario.Attributes[0].Value == event.request.userAttributes.email){
return {};
}
});
callback(event);
}
});
}
但我不明白我做错了什么,lambda 执行 returns...
Object { code: "UserLambdaValidationException", name: "UserLambdaValidationException", message: "PreSignUp failed with error [object Object]." }
有什么想法吗?
我正在做一个 VUE+Amplify 项目,它快完成了,但 cognito 不提供邮件重复检查,所以我必须手动进行,因为我们知道 AWS 有一些触发器我正在使用 PreSignUp调用 Lambda 函数,我的代码是:
var AWS = require("aws-sdk");
const cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
exports.handler = function(event, context, callback) {
var params = {
UserPoolId: "us-east-1_xxxXXXxXX",
AttributesToGet: ["email"]
};
cognitoidentityserviceprovider.listUsers(params, (err, data) => {
if (err) {
console.log(err, err.stack);
callback(err) // here is the error return
} else {
data.Users.forEach(function(usuario) {
if(usuario.Attributes[0].Value == event.request.userAttributes.email){
return {};
}
});
callback(event);
}
});
}
但我不明白我做错了什么,lambda 执行 returns...
Object { code: "UserLambdaValidationException", name: "UserLambdaValidationException", message: "PreSignUp failed with error [object Object]." }
有什么想法吗?