AnomalyInnovations / serverless-stack-demo-api

Source for the demo app API in the Serverless Stack Guide
https://demo.serverless-stack.com
MIT License
517 stars 197 forks source link

The cognitoIdentityId used for the userId key in the DB table can change #13

Closed codedplanetuk closed 6 years ago

codedplanetuk commented 6 years ago

Using the cognitoIdentityId as the userId key in the table can cause an issue, as the cognitoIdentityId can change.

If you go on to implement forgot password functionality, you will find that the cognitoIdentityId will change during a password reset. This means any notes you had with the old cognitoIdentityId will not be retrieved for the user who has changed password.

I'm thinking to store the cognito username as the userId key instead, as this seems to persist even if you do a password reset.

Has anyone else run into this issue? Any suggestions?

jayair commented 6 years ago

@codedplanetuk I don't think the Cognito Identity Id changes when you reset your password. We have this running in production with the password reset functionality. Are you sure that's what you are seeing?

codedplanetuk commented 6 years ago

Apologies my bad. A ran another test and the cognitoIdentityId did not change. I think I must have deleted the entire user from the user table which caused the issue. Will close this thread. Thanks.