简体   繁体   English

如何使用GoLang拒绝注册触发器

[英]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.

相关问题 预注册 Lambda 触发 autoConfirmUser 不工作 - Pre Sign-up Lambda Trigger autoConfirmUser not working 如何在 Cognito 的注册过程中重新发送确认码 - How to resend confirmation code in Cognito's sign-up process Cognito 从 Pre Sign-up Lambda 触发器发送什么样的事件 - What kind of event does Cognito send from Pre Sign-up Lambda Trigger AWS-Amplify 的注册问题 - Sign-Up issue with AWS-Amplify 如何确定AWS的CPUUtilization是否是我的网站注册超时的原因? - How can I tell if CPUUtilization in AWS is the reason my website sign-up is timing out? 用于注册和忘记密码的不同电子邮件验证消息 - Different email verification messages for sign-up and forgot-password 拒绝 Cognito 用户池中的注册请求 - Denying a Sign-up request in Cognito User Pools AWS Cognito 托管的注册和登录页面的空白页面 - Empty page for the sign-up and sign-in pages hosted by AWS Cognito 是否存在适用于AWS Cognito Web应用程序(而非移动应用程序)的注册/登录GUI功能? - Is there a Sign-up/Sign-in GUI functionality for AWS Cognito web apps (not mobile apps)? 为使用 AWS(特别是 S3 存储桶)托管的网站页面创建注册表单(类似于 mailchimp) - Creating a sign-up form (similar to mailchimp) for a website page that is hosted using AWS (S3 bucket specifically)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM