4

I'm fairly new to full-stack development and this question is more of a best practice question/am I doing it right.

I am building a website that uses aws Cognito for authentication, but I also wanted to save a variety of stats in RDS for each user. Currently I just create the user using Auth from AWS on the client side. When I add the RDS code, should I make the calls to create the AWS user and RDS user row from the client side? Or should I send the information to my backend API to do it? I'm mainly concerned with accidentally creating one but not the other if I do it on the client side.

Also, if what I am doing seems incorrect or their is a better way to do it please let me know.

P. Vaden
  • 98
  • 8
  • 3
    You could either (1) invoke your backend API method that creates the user in RDS after a successful callback from Cognito on client side (and possibly double-check that the user exists in Cognito from backend) or (2) you could create a Cognito "Post confirmation" [trigger](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-lambda-trigger-examples.html#aws-lambda-triggers-post-confirmation-example) that creates the user record in RDS after the user is confirmed in Cognito. – Khalid T. Apr 01 '18 at 21:22

0 Answers0