Repository navigation
feat(Layout): add IsAutoNavigateWhenNotAuthorize parameter - #8503
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds Layout.IsAutoNavigateWhenNotAuthorize, preserving the existing automatic redirect behavior by default while allowing consumers to disable unauthorized navigation; the location-change handler exits before authorization navigation logic when disabled. Sequence diagram for configurable unauthorized navigationsequenceDiagram
participant Browser
participant Layout
participant Navigation
participant Authorizing
Browser->>Navigation: LocationChanged
Navigation->>Layout: Navigation_LocationChanged
alt IsAutoNavigateWhenNotAuthorize is false
Layout-->>Navigation: return
else IsAutoNavigateWhenNotAuthorize is true
Layout->>Authorizing: OnAuthorizing
Authorizing-->>Layout: authorization result
Layout-->>Navigation: navigate to NotAuthorizeUrl when unauthorized
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/BootstrapBlazor/Components/Layout/Layout.razor.cs" line_range="733" />
<code_context>
private void Navigation_LocationChanged(object? sender, LocationChangedEventArgs e)
{
+ // 如果未开启自动跳转未授权地址则不处理
+ if (!IsAutoNavigateWhenNotAuthorize)
+ {
+ return;
</code_context>
<issue_to_address>
**Protected routes render unchecked**
When `IsAutoNavigateWhenNotAuthorize` is false and a route relies on `OnAuthorizing` for authorization, `Navigation_LocationChanged` returns before invoking `OnAuthorizing` or updating `_authenticated`, so callback-based authorization is skipped and the layout can render protected content or keep showing `Main` instead of `NotAuthorized`.
Always run the authorization callback and update the authorization state; use `IsAutoNavigateWhenNotAuthorize` only to gate the redirect.
Also at `src/BootstrapBlazor/Components/Layout/Layout.razor.cs:734-736`.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: src/BootstrapBlazor/Components/Layout/Layout.razor.cs:733
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8503 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 777 777
Lines 35159 35160 +1
=========================================
+ Hits 35159 35160 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Sourcery withdrew this approval because the latest commits introduced blocking findings.
Link issues
fixes #8502
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Allow applications to disable automatic navigation when authorization fails while preserving the existing redirect behavior by default.
New Features:
Tests: