Improved first-time login algorithm on rusro#15
Conversation
|
Warning Review limit reached
More reviews will be available in 37 minutes and 22 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesRuSroAuthService Authentication Refactoring
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
🧹 Nitpick comments (1)
Plugins/RSBot.General/Components/RuSroAuthService.cs (1)
163-166: 💤 Low valueConsider using per-request headers instead of DefaultRequestHeaders.
Modifying
DefaultRequestHeaderson a staticHttpClientis not thread-safe. While the current desktop app flow appears single-threaded, this pattern can cause header corruption ifTokenResponseis ever called concurrently.A more robust approach uses
HttpRequestMessage:♻️ Suggested refactor
- client.DefaultRequestHeaders.Remove("Hardware-Id"); - client.DefaultRequestHeaders.Remove("Launcher-Id"); - client.DefaultRequestHeaders.Add("Hardware-Id", hwid); - client.DefaultRequestHeaders.Add("Launcher-Id", launcherId); - - using (tokenRequestContent) - { - var tokenResponse = await client.PostAsync(endpoint, tokenRequestContent); + using (tokenRequestContent) + using (var request = new HttpRequestMessage(HttpMethod.Post, endpoint) { Content = tokenRequestContent }) + { + request.Headers.Add("Hardware-Id", hwid); + request.Headers.Add("Launcher-Id", launcherId); + var tokenResponse = await client.SendAsync(request); var tokenResponseContent = await tokenResponse.Content.ReadAsStringAsync(); return tokenResponseContent; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Plugins/RSBot.General/Components/RuSroAuthService.cs` around lines 163 - 166, TokenResponse currently mutates the shared HttpClient.DefaultRequestHeaders (removing/adding "Hardware-Id" and "Launcher-Id"), which is not thread-safe; instead create a per-request HttpRequestMessage inside TokenResponse, set the hwid and launcherId on request.Headers (or request.Content.Headers if appropriate) and send that message with the existing HttpClient (e.g., SendAsync/PostAsync overload that accepts HttpRequestMessage); remove all DefaultRequestHeaders mutation and ensure TokenResponse uses the request-local headers so concurrent calls cannot clash.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Plugins/RSBot.General/Components/RuSroAuthService.cs`:
- Around line 163-166: TokenResponse currently mutates the shared
HttpClient.DefaultRequestHeaders (removing/adding "Hardware-Id" and
"Launcher-Id"), which is not thread-safe; instead create a per-request
HttpRequestMessage inside TokenResponse, set the hwid and launcherId on
request.Headers (or request.Content.Headers if appropriate) and send that
message with the existing HttpClient (e.g., SendAsync/PostAsync overload that
accepts HttpRequestMessage); remove all DefaultRequestHeaders mutation and
ensure TokenResponse uses the request-local headers so concurrent calls cannot
clash.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 34447214-5332-41bc-95b2-3bc85647de8d
📒 Files selected for processing (1)
Plugins/RSBot.General/Components/RuSroAuthService.cs
Summary by CodeRabbit