I'm developing an app with a React Native frontend and a serverless backend which is the API Gateway REST API to invoke lambdas.
I'm also using AWS Cognito and a post-confirmation lambda trigger to create the user in the db. The lambda retrieves the user name and email from the trigger, and saves those details in db.
Now I am working on an endpoint to update the user on a POST request from the frontend, and I was wondering what the best practice was on identifying the user that the backend should update from the details given by the frontend.
Since the field that is unique is the user_email, I was thinking of encrypting the user email from the frontend and passing it as query to the call to the rest api endpoint. Then the invoked lambda will decrypt the query and identify which user to update.
I also thought of passing the id of the user as query, but the id is of type serial PRIMARY KEY and is created in the db when the user registers and is verified through AWS Amplify (with AWS Cognito). So the frontend has no knowledge of what the id is for the user yet, and would have to make a call to the backend to get the created user, which is an extra API call.
Could you please advise a safe way to achieve this? Thank you so much!