Skip to content

core: fix logout all sessions behavior#1178

Merged
undefined-moe merged 2 commits into
hydro-dev:masterfrom
renbaoshuo:fix/del-token-by-uid
Jun 8, 2026
Merged

core: fix logout all sessions behavior#1178
undefined-moe merged 2 commits into
hydro-dev:masterfrom
renbaoshuo:fix/del-token-by-uid

Conversation

@renbaoshuo

@renbaoshuo renbaoshuo commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Clearing user credentials now removes only session tokens rather than all token types.
    • Token removal logic updated to support scoped deletions so other token types are preserved when clearing sessions.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fc04c196-1bf9-4b08-8288-2f9f864781ee

📥 Commits

Reviewing files that changed from the base of the PR and between cbbb18f and 1dda99d.

📒 Files selected for processing (1)
  • packages/hydrooj/src/model/token.ts

Walkthrough

TokenModel.delByUid gained an optional tokenType parameter and now builds a deletion filter { uid, ...(tokenType) } before calling deleteMany. The postDeleteAllTokens handler was updated to call delByUid(uid, token.TYPE_SESSION), so only session tokens for the current user are deleted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • undefined-moe
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing the 'logout all sessions' behavior by modifying token deletion to only target session tokens rather than all token types.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/hydrooj/src/model/token.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/hydrooj/src/model/token.ts`:
- Around line 105-106: TokenModel.delByUid currently calls
TokenModel.coll.deleteMany({ uid, tokenType }) which passes tokenType: undefined
into the Mongo filter; change delByUid to build the query object conditionally
(e.g., start with { uid } and only add tokenType when tokenType !== undefined)
and then call TokenModel.coll.deleteMany(query) so undefined tokenType is not
serialized as null and numeric tokenType documents are matched correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2b93e609-11fd-47dc-90fa-46f0a7f3aeb4

📥 Commits

Reviewing files that changed from the base of the PR and between 809d1ac and cbbb18f.

📒 Files selected for processing (2)
  • packages/hydrooj/src/handler/home.ts
  • packages/hydrooj/src/model/token.ts

Comment thread packages/hydrooj/src/model/token.ts Outdated
@undefined-moe undefined-moe merged commit dc5bcff into hydro-dev:master Jun 8, 2026
6 checks passed
@renbaoshuo renbaoshuo deleted the fix/del-token-by-uid branch June 15, 2026 05:41
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