sub attribute on Cognito Pre Sign Up lambda

0

I'd like to have access to the sub attribute on the pre-sign-up trigger function when customer is signin up with external IdP. Will this be possible in the near future?

Use case is that the authorization layer of the application is handled in the backend, so I need to insert the user to database in the sign up process.

Related thread: https://forums.aws.amazon.com/thread.jspa?threadID=309346

teemu
已提問 2 年前檢視次數 1162 次
1 個回答
1
已接受的答案

Hi,

SUB is not available in pre-signup trigger because the user hasn't been created at this stage (it is "pre" sign-up, meant for validation to decide whether to allow the sign-up to continue or reject the request). If you want to propagate the SUB to backend you should use PostConfirmation trigger for this, this will be triggered after the user has been created and confirmed.

AWS
專家
已回答 2 年前
  • Thanks for the quick reply.

    Does post confirmation trigger execute before the authentication flow is complete? We need the user to be present in the database before user is redirected back to the frontend after the sign up?

  • I did some experimentation and post confirmation is indeed part of the external provider sign up flow. That solves the issue, thanks! The documentation could be more clear on this though.

    Noted also that when using adminCreateUser, the post confirmation doesn't trigger. I can imagine there would be many use cases for using a trigger which runs every time after the user has been created to the pool, no matter which way the creation happened.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南