fix(identity): reduce SessionService complexity#1194
Merged
iammukeshm merged 2 commits intodevelopfrom Jan 27, 2026
Merged
Conversation
added 2 commits
January 26, 2026 20:38
…terfaces - Create ICurrentUserService interface combining ICurrentUser and ICurrentUserInitializer - Create IRequestContextService interface extending IRequestContext - Update CurrentUserService to implement ICurrentUserService (internal sealed) - Update RequestContextService to implement IRequestContextService (internal sealed) - Update DI registration to register services with their new interfaces - Maintain backward compatibility with existing ICurrentUser and IRequestContext consumers Closes #1180
Refactored SessionService.cs to reduce cyclomatic complexity: - Extract DeviceTypeClassifier: Moved device type detection logic to a dedicated static helper class, reducing CC from 9 to 3 (uses LINQ Any) - Add SessionCleanupHostedService: Background service for automated session cleanup (runs hourly, removes sessions expired >30 days) - Register hosted service in IdentityModule for automatic cleanup Changes: - SessionService.cs: ~350 lines (was 372), removed GetDeviceType method - DeviceTypeClassifier.cs: New helper class (~40 lines) - SessionCleanupHostedService.cs: New background service (~65 lines) - IdentityModule.cs: Register SessionCleanupHostedService Build: 0 errors, 0 new warnings Closes #1177
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactored SessionService.cs to reduce cyclomatic complexity as identified in Issue #1177.
Changes
1. Extract DeviceTypeClassifier (New File)
SessionService.GetDeviceTypeto a dedicated static helper classAny()for cleaner keyword matching2. Add SessionCleanupHostedService (New File)
IdentityModule3. SessionService Simplification
GetDeviceTypemethodDeviceTypeClassifier.Classify()Files Changed
SessionService.csDeviceTypeClassifier.csSessionCleanupHostedService.csIdentityModule.csBuild Status
✅ 0 errors, 0 new warnings
Closes #1177