fix: remove [Authorize] from Dashboard, add internal auth check

Root cause: [Authorize] attribute was blocking /dashboard access before
Blazor auth state could be established, causing redirect to /not-found.

Solution:
- Remove [Authorize] from Dashboard.razor
- Add authentication check in OnInitializedAsync
- If not authenticated, redirect to login internally
- Reduced wait time from 6s to 3s in login.html

This allows:
1. /dashboard to load immediately
2. Blazor auth state to initialize
3. Dashboard to verify user is authenticated
4. Redirect to login if not authenticated

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-07-06 01:24:44 +09:00
parent 84e5784b66
commit 53ae2fcc51
6 changed files with 215 additions and 7 deletions
@@ -1,7 +1,9 @@
@page "/dashboard"
@attribute [Authorize]
@using QuantEngine.Core.Infrastructure
@using Microsoft.AspNetCore.Components.Authorization
@inject HttpClient Http
@inject AuthenticationStateProvider AuthStateProvider
@inject NavigationManager NavManager
<PageTitle>QuantEngine - Admin Dashboard</PageTitle>
@@ -240,6 +242,15 @@
protected override async Task OnInitializedAsync()
{
// Check authentication
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
if (!authState.User.Identity?.IsAuthenticated ?? true)
{
// Not authenticated - redirect to login
NavManager.NavigateTo("/login.html", forceLoad: true);
return;
}
try
{
// Load operational report
@@ -324,14 +324,13 @@
// 로그인 성공 메시지 표시
alertDiv.className = 'alert alert-success show';
alertDiv.textContent = '로그인 성공! 대시보드로 이동합니다. (Blazor 초기화 중...)';
alertDiv.textContent = '로그인 성공! 대시보드로 이동합니다.';
// Blazor 앱이 로드되고 localStorage에서 토큰을 읽을 시간을 충분히 제공
// 3초 대기 후 대시보드
console.log('[Login] Waiting 3 seconds for Blazor to initialize...');
// Blazor 앱이 로드될 시간 제공
// (대시보드제 [Authorize] 없이 로드되고, 내부에서 인증 체크)
console.log('[Login] Token saved. Redirecting in 3 seconds...');
setTimeout(() => {
console.log('[Login] Redirecting to dashboard');
console.log('[Login] Token in localStorage:', localStorage.getItem('quant_admin_access_token') ? 'YES' : 'NO');
console.log('[Login] Navigating to dashboard');
window.location.href = '/dashboard';
}, 3000);
} else {