[英]How to reject sign-up trigger with GoLang
I've successfully created a lambda function using Go for the pre sign-up trigger of AWS Cognito. 我已成功使用Go创建了一个lambda函数,用于AWS Cognito的预注册触发器。 My problem is that I'm not being able to deny/reject the user if a custom field is not valid (based on custom logic).
我的问题是,如果自定义字段无效(基于自定义逻辑),我无法拒绝/拒绝用户。
I'm returning an error as described in AWS Cognito trigger's guide: 我正在返回AWS Cognito触发器指南中描述的错误:
return event, fmt.Errorf("Invalid value for field 'custom:myField'")
also I've tried this options: 我也试过这个选项:
returning an empty event (nil is not allowed for the event): 返回空事件(事件不允许nil):
var emptyEvent events.CognitoEventUserPoolsPreSignup return emptyEvent, fmt.Errorf("Invalid value for field 'custom:myField'")
changing ValidationData in the original event: 在原始事件中更改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'")
changing UserAttributes in the original event 更改原始事件中的UserAttributes
event.Request.UserAttributes["email"] = "" return event, fmt.Errorf("Invalid value for field 'custom:myField'")
All those methods are failing, the user is always created in the User Pool. 所有这些方法都失败了,用户总是在用户池中创建。
What should be the correct way to reject the sign-up request using GoLang lambda function? 使用GoLang lambda函数拒绝注册请求的正确方法是什么?
Looks like something changed on AWS Cognito Lambda triggers, since today I tried the following source code and it worked as expected: 看起来在AWS Cognito Lambda触发器上发生了一些变化,因为今天我尝试了以下源代码,它按预期工作:
func handler(event events.CognitoEventUserPoolsPreSignup) (events.CognitoEventUserPoolsPreSignup, error) {
fmt.Println(event)
return event, fmt.Errorf("TESTING LAMBDA ERRORS WITH GOLANG")
}
Also, the previous source code that was not working as expected when I posted this question is currently working (with no changes on my side). 此外,当我发布此问题时,之前未按预期工作的源代码目前正在工作(我没有任何更改)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.