User ID on Client Side or Not?
Hi,
I’m building a Feed application, somewhat like Facebook. So far, I’ve implemented it in a way that avoids fetching or using user IDs on the client side. For example, when fetching posts or liking/commenting on one, I send a request to the server with just the post ID. On the server side, I handle the like or comment by finding the post using its ID, which is tied to a user ID, and update it as needed. This way, I don’t need to use the user ID on the client side. Similarly, when fetching data for myself as an authenticated user, I get my user ID directly from my identity on the server, so there’s no need to pass my user ID explicitly.
However, if I want to implement a profile page, I’ll need to locate and display a specific user’s profile. For this, I assume I’ll need the user ID available on the client side. Would this approach be fine?
What is your opinion about?
Thanks in advance!
I’m building a Feed application, somewhat like Facebook. So far, I’ve implemented it in a way that avoids fetching or using user IDs on the client side. For example, when fetching posts or liking/commenting on one, I send a request to the server with just the post ID. On the server side, I handle the like or comment by finding the post using its ID, which is tied to a user ID, and update it as needed. This way, I don’t need to use the user ID on the client side. Similarly, when fetching data for myself as an authenticated user, I get my user ID directly from my identity on the server, so there’s no need to pass my user ID explicitly.
However, if I want to implement a profile page, I’ll need to locate and display a specific user’s profile. For this, I assume I’ll need the user ID available on the client side. Would this approach be fine?
What is your opinion about?
Thanks in advance!