[英]How to reject sign-up trigger with GoLang
我已成功使用Go创建了一个lambda函数,用于AWS Cognito的预注册触发器。 我的问题是,如果自定义字段无效(基于自定义逻辑),我无法拒绝/拒绝用户。
我正在返回AWS Cognito触发器指南中描述的错误:
return event, fmt.Errorf("Invalid value for field 'custom:myField'")
我也试过这个选项:
返回空事件(事件不允许nil):
var emptyEvent events.CognitoEventUserPoolsPreSignup return emptyEvent, fmt.Errorf("Invalid value for field 'custom:myField'")
在原始事件中更改ValidationData:
event.Request.ValidationData = map[string]string{"custom:myField": "Invalid value for field 'custom:myField."} return event, fmt.Errorf("Invalid value for field 'custom:myField'")
更改原始事件中的UserAttributes
event.Request.UserAttributes["email"] = "" return event, fmt.Errorf("Invalid value for field 'custom:myField'")
所有这些方法都失败了,用户总是在用户池中创建。
使用GoLang lambda函数拒绝注册请求的正确方法是什么?
看起来在AWS Cognito Lambda触发器上发生了一些变化,因为今天我尝试了以下源代码,它按预期工作:
func handler(event events.CognitoEventUserPoolsPreSignup) (events.CognitoEventUserPoolsPreSignup, error) {
fmt.Println(event)
return event, fmt.Errorf("TESTING LAMBDA ERRORS WITH GOLANG")
}
此外,当我发布此问题时,之前未按预期工作的源代码目前正在工作(我没有任何更改)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.