Refactor CurrentUserService contract (#667)#672
Merged
ziagham merged 2 commits intoflowsynx:masterfrom Nov 8, 2025
Merged
Conversation
ziagham
requested changes
Nov 8, 2025
Member
ziagham
left a comment
There was a problem hiding this comment.
The only remaining part that hasn’t been updated is in WorkflowHttpListenerExtensions
File: /src/FlowSynx/Extensions/WorkflowHttpListenerExtensions.cs at line 23
var userId = userService.UserId;This should be updated to:
var userId = userService.UserId();
|
ziagham
approved these changes
Nov 8, 2025
ziagham
approved these changes
Nov 8, 2025
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
This PR updates ICurrentUserService to use explicit methods instead of properties, which makes the intent clearer and avoids the confusion that can happen when property access has side effects. The new XML docs help explain how each method should be used, which matches the guidance we follow in other core services.
CurrentUserService has been updated accordingly, including centralizing how authentication failures are turned into FlowSynx exceptions. This keeps the logging and error behavior consistent across the app. The ValidateAuthentication flow now goes through the same entry point as well.
All existing consumers were switched over to the new method-based API, and I added focused unit tests to clearly capture the expected behavior around claims, roles, and what happens when a user isn’t authenticated.
I wasn’t able to run dotnet test locally since my environment only has SDK 8.0.415 and the repo targets net9.0, but the changes are straightforward and contained.
Closes #667.