Skip to content

Comments

fix(auth): resolve session user by token subject ID#56

Open
tomerqodo wants to merge 4 commits intocursor_only-issues-20260113-cursor_completion_base_fixauth_resolve_session_user_by_token_subject_id_pr290from
cursor_only-issues-20260113-cursor_completion_head_fixauth_resolve_session_user_by_token_subject_id_pr290
Open

fix(auth): resolve session user by token subject ID#56
tomerqodo wants to merge 4 commits intocursor_only-issues-20260113-cursor_completion_base_fixauth_resolve_session_user_by_token_subject_id_pr290from
cursor_only-issues-20260113-cursor_completion_head_fixauth_resolve_session_user_by_token_subject_id_pr290

Conversation

@tomerqodo
Copy link

@tomerqodo tomerqodo commented Jan 20, 2026

Benchmark PR from qodo-benchmark#290


Note

Improves server-side session resolution and adds coverage.

  • Parse token.sub to userId, warn and return null if invalid; minor refactor to inline lowercased email in findUnique query
  • New __mocks__/getServerSession.mocks.ts providing Prisma, logger, repositories, utilities, and token/user factories
  • New getServerSession.test.ts with cases for token validation, user ID validation, user lookup/resolution via sub, session shape, and ensuring queries use id

Written by Cursor Bugbot for commit 04dcede. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


const userFromDb = await prisma.user.findUnique({
where: { email },
where: { email: token.email.toLowerCase() },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User lookup still uses email instead of ID

High Severity

The userId is parsed from token.sub and validated, but the database query at line 64-65 still looks up users by email instead of by id. The PR intends to resolve users by token subject ID, and the tests expect where: { id: userId }, but the implementation uses where: { email: token.email.toLowerCase() }. The computed userId variable is never used for its intended purpose.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants