Skip to content

Conversation

@ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Aug 6, 2025

closes #11240

Summary by CodeRabbit

  • Bug Fixes

    • Revoking all user sessions now keeps the current session active instead of logging the user out of all sessions.
  • Chores

    • Removed unused error messages related to revoking all user sessions from both English and Persian resource files.

Fixed RevokeAllUserSessions to exclude current session instead of blocking the operation
Removed redundant error message for removing all user sessions
Updated logic to use session ID comparison for better precision

Transferred from: 11237
@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Walkthrough

The RevokeAllUserSessions method in the user management controller was updated to exclude the current session from revocation instead of throwing an exception when a user attempts to revoke all their own sessions. Corresponding error message resource strings were removed from both English and Persian resource files.

Changes

Cohort / File(s) Change Summary
User Session Revocation Logic
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/UserManagementController.cs
Modified logic in RevokeAllUserSessions to exclude the current session from revocation instead of throwing an exception.
Resource String Removal (English)
src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.resx
Removed the resource string UserCantRemoveAllItsSessionsErrorMessage.
Resource String Removal (Persian)
src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.fa.resx
Removed the Persian resource entry for UserCantRemoveAllItsSessionsErrorMessage.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UserManagementController
    participant SessionStore

    User->>UserManagementController: Request to revoke all sessions
    UserManagementController->>SessionStore: Get all sessions for user
    UserManagementController->>SessionStore: Exclude current session from revocation
    UserManagementController->>SessionStore: Revoke all other sessions
    UserManagementController-->>User: Respond with success
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Assessment against linked issues

Objective Addressed Explanation
Update user controller to remove all user sessions except current instead of throwing an exception (#11240)
Remove related error message resource strings (#11240)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Poem

A bunny hopped through code so bright,
No more errors to give you a fright!
Now sessions stay, except your own,
All others swiftly overthrown.
Resource strings gone, the logic’s clear—
This rabbit brings you session cheer! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 3f69159 and 65cb1b4.

📒 Files selected for processing (3)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/UserManagementController.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.fa.resx (0 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.resx (0 hunks)
💤 Files with no reviewable changes (2)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.resx
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.fa.resx
🔇 Additional comments (3)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/UserManagementController.cs (3)

102-103: LGTM! Good approach to get the current session ID.

The addition of userSessionId variable to capture the current user's session ID is a clean implementation that enables excluding the current session from revocation.


105-107: LGTM! SignalR connection filtering correctly excludes current session.

The modification to exclude the current session (us.Id != userSessionId) from the SignalR connection IDs query is correct and prevents the current session's SignalR connection from being terminated.


110-110: LGTM! Database deletion properly excludes current session.

The core logic change correctly filters out the current session (us.Id != userSessionId) from the deletion operation, which fulfills the PR objective of removing all sessions except the current one instead of throwing an exception.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ysmoradi ysmoradi merged commit e5e49ac into bitfoundation:develop Aug 6, 2025
2 of 3 checks passed
@ysmoradi ysmoradi deleted the feature/user-session-management-fix branch August 6, 2025 13:58
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.

bit Boilerplate user controller must remove all user sessions except current instead of throwing an exception

1 participant