Per-User Doctor List Access

Job ID: 40419076

Budget: $10 – $90 USD

My app already handles sign-in with username and password and stores everything in a relational database (MySQL/PostgreSQL). I have three tables:

• users
• doctors


What I need now is the logic that, immediately after a successful login, returns only the doctors connected to that specific user. The same rule must apply to every page, API endpoint, or query that surfaces doctor data, so a user never sees records that aren’t theirs.



1. Adjust the current queries or create a middleware/service layer that filters by user_id from the session/token.
2. Provide clear comments or brief documentation so I can extend the filter when I add new roles.
3. Deliver tested code (SQL statements, ORM scope, or framework middleware—whichever fits) that plugs straight into my existing codebase.

If you’ve implemented row-level security or scoped queries before, this will be quick work. Just make sure the logged-in user’s context drives every doctor lookup, and you’ll have met the requirement.