fix: sanitize user API responses#402
Conversation
|
@akshayad2006-cmd is attempting to deploy a commit to the Adarsh's projects Team on Vercel. A member of the Team first needs to authorize it. |
MRIARC-08
left a comment
There was a problem hiding this comment.
@akshayad2006-cmd I can’t merge this version. Sanitizing user responses is the right goal, but the PR changes auth behavior while doing it.
Local check:
-
pnpm testfails insrc/modules/auth/auth.service.test.tsbecause access tokens now get hard-codedrole: "USER"andisProfileCompleted: falseinstead of using the real user role/profile state. -
The response DTO/select layer should remove sensitive fields from API responses, but it should not change token claims or login/register/refresh behavior.
-
Please also remove the unrelated
pnpm-lock.yamlchurn unless a dependency actually changed.Keep the public user shape, but preserveuser.roleanduser.firstTime/profile-completion values where the auth service builds tokens.
|
Hi @MRIARC-08 Token claims now use the real user role and firstTime/profile-completion values instead of hardcoded values. I also updated the auth service tests to assert sanitized user responses without password exposure. Verified with:
|
MRIARC-08
left a comment
There was a problem hiding this comment.
@akshayad2006-cmd Good progress: the auth service test regression is fixed now.
Local checks from my side:
pnpm test src/modules/auth/auth.service.test.tspasses.pnpm exec tsc --noEmitpasses.- Focused ESLint still fails on Prettier issues in the touched auth/user files, plus one unused
passworddestructure warning insrc/modules/user/user.repository.ts.
Main blocker: the PR still changes pnpm-lock.yaml unrelated to this auth sanitization work and removes the security override section from the lockfile. Please restore the lockfile to current main unless this PR intentionally changes dependencies, which it should not.
After that, run the formatter on the touched files and remove the unused destructure warning. No broader rewrite needed.
Description
Authentication and profile endpoints were returning complete Prisma User records, which exposed sensitive information such as password hashes and internal account fields to clients.
This change introduces a consistent public user contract and ensures that only fields required by the frontend are returned from register, login, OAuth, and profile endpoints.
Changes Made
Impact
Before
After
Files Modified
Related issue
Fixes #323