簡體   English   中英

如何使用GoLang拒絕注冊觸發器

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM