feat: implement IUserRegistrationManager interface and refactor RegisterAsync on UserRegistrationManager#4837
Conversation
…registration logic
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 44 minutes and 40 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR introduces an Changes
Sequence DiagramsequenceDiagram
actor Client
participant TokenAuthController
participant IUserRegistrationManager
participant IRepository
participant UnitOfWork
participant Database
Client->>TokenAuthController: POST external user registration
TokenAuthController->>IUserRegistrationManager: RegisterAsync(user details)
IUserRegistrationManager->>Database: Create new user
IUserRegistrationManager->>UnitOfWork: SaveChangesAsync()
IUserRegistrationManager-->>TokenAuthController: Return registered user
TokenAuthController->>UnitOfWork: Create new transaction scope (RequiresNew)
TokenAuthController->>IRepository: GetAsync(user.Id)
IRepository->>Database: Load persisted user
Database-->>IRepository: Return user
IRepository-->>TokenAuthController: Return persisted user
TokenAuthController->>TokenAuthController: Add UserLogin to persistedUser.Logins
TokenAuthController->>UnitOfWork: CompleteAsync()
UnitOfWork->>Database: Commit UserLogin changes
TokenAuthController-->>Client: Return persisted user with login
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shesha-core/src/Shesha.Application/Authorization/TokenAuthController.cs`:
- Around line 338-353: The code opens a new transaction with
UnitOfWorkManager.Begin(TransactionScopeOption.RequiresNew) and then calls
_userRepository.GetAsync(user.Id), which can fail because the newly created user
from RegisterAsync is not yet committed; instead perform the user creation and
login addition in the same unit of work: either remove the RequiresNew Begin
call and use the ambient/current UOW (so directly add the new UserLogin to
persistedUser.Logins before completing the existing UOW) or move the
RegisterAsync call into a single explicit UOW scope so that RegisterAsync and
the UserLogin addition occur within the same UnitOfWork; update the code around
UnitOfWorkManager.Begin, RegisterAsync, and persistedUser.Logins.Add to ensure
atomicity.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 128e3279-0d53-4152-8d5f-bcf15deb402b
📒 Files selected for processing (4)
shesha-core/src/Shesha.Application/Authorization/TokenAuthController.csshesha-core/src/Shesha.Framework/Authorization/Users/IUserRegistrationManager.csshesha-core/src/Shesha.Framework/Authorization/Users/UserRegistrationManager.csshesha-core/src/Shesha.Framework/SheshaFrameworkModule.cs
#4828
Summary by CodeRabbit
Bug Fixes
Refactor