fix: reload page after login to properly restore Blazor authentication state
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m36s

Problem: Login succeeds (tokens saved to localStorage) but dashboard stays in
'loading' state. Root cause: JavaScript login redirects to dashboard with
location.href, but WASM hasn't bootstrapped yet, so CustomAuthenticationStateProvider
hasn't read tokens from localStorage yet.

Solution: After saving tokens, reload current page instead of redirecting.
Page reload allows:
1. WASM to bootstrap
2. CustomAuthenticationStateProvider.GetAuthenticationStateAsync() to run
3. Tokens to be restored from localStorage
4. [Authorize] pages to detect authenticated user and render

Flow:
- User submits login form (JavaScript)
- POST /api/auth/login succeeds
- Save tokens to localStorage
- 200ms delay
- location.reload() to reload login page
- WASM boots + auth state updates
- Blazor recognizes authenticated user, auto-redirects to dashboard
- Dashboard renders successfully

Result: Clean authentication flow without hanging spinners.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 13:24:32 +09:00
parent 6fb17df2c2
commit e24d683d52
+4 -3
View File
@@ -340,10 +340,11 @@ window.taxbaikAdminSession = {
localStorage.removeItem('admin-remember-checkbox');
}
// 토큰 저장 후 약간의 지연을 두고 대시보드로 이동
// 이렇게 하면 CustomAuthenticationStateProvider가 localStorage에서 토큰을 복원할 시간이 생김
// 토큰 저장 후 현재 페이지 새로고침
// 이렇게 하면 WASM이 부팅되면서 CustomAuthenticationStateProvider가 localStorage에서
// 토큰을 복원하고, 그 후 자동으로 인증된 사용자를 대시보드로 리다이렉트함
setTimeout(() => {
window.location.href = '/taxbaik/admin/dashboard';
window.location.reload();
}, 200);
} catch (error) {
window.taxbaikAdminSession.traceUiState('admin-login', `submit failed: ${error?.message || 'login failed'}`);