refactor: handle optional user inside userservice, replace @autowire #227
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
backend
ci
docs
frontend
lgtm
blocked
lgtm
done
lgtm
need 1
size
huge
size
large
size
medium
size
small
No milestone
No project
No assignees
3 participants
Due date
No due date set.
Dependencies
No dependencies set.
Reference: SZUT/casino#227
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refactor-get-current-user"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
--body APPROVE ✅
This refactoring improves code quality significantly:
Positive Changes:
✅ Better dependency injection: Removed @Autowired annotations in favor of constructor injection, which is the recommended Spring practice for better testability and immutability
✅ Cleaner user handling: Centralized Optional handling in UserService.getCurrentUser() - now returns UserEntity directly and throws UserNotFoundException internally, eliminating repetitive null checks
✅ Reduced boilerplate: Removed 50+ lines of repetitive Optional.isEmpty() checks across multiple controllers
✅ Consistent error handling: UserNotFoundException is now consistently thrown from a single location
✅ Code maintainability: Easier to modify user retrieval logic in the future since it's centralized
Code Quality:
The refactoring successfully eliminates code duplication while maintaining the same error behavior. The centralized approach in UserService.getCurrentUser() is much cleaner than the previous scattered Optional handling.