From 8b1127b2706fac0f1a8a93fb3477d1c2fdbff61c Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Sun, 5 Jul 2026 17:30:26 +0900 Subject: [PATCH] fix(admin): log login response details --- src/TaxBaik.Web/wwwroot/js/admin-session.js | 56 +++++++++++++++------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/src/TaxBaik.Web/wwwroot/js/admin-session.js b/src/TaxBaik.Web/wwwroot/js/admin-session.js index a470981..6b0455c 100644 --- a/src/TaxBaik.Web/wwwroot/js/admin-session.js +++ b/src/TaxBaik.Web/wwwroot/js/admin-session.js @@ -1,14 +1,3 @@ -// Debug 환경에서 .pdb 파일 요청 차단 (WASM 부팅 최적화) -if (window.taxbaikBlockPdb) { - const originalFetch = window.fetch; - window.fetch = function(url, ...args) { - if (typeof url === 'string' && url.includes('.pdb')) { - return Promise.reject(new TypeError('Blocked: pdb')); - } - return originalFetch.apply(window, [url, ...args]); - }; -} - window.taxbaikAdminSession = { clientLogState: { enabled: true, @@ -218,6 +207,30 @@ window.taxbaikAdminSession = { } }, + getLocalStorageItem: function (key) { + try { + return localStorage.getItem(key); + } catch { + return null; + } + }, + + setLocalStorageItem: function (key, value) { + try { + localStorage.setItem(key, value); + } catch { + // Ignore storage errors. + } + }, + + removeLocalStorageItem: function (key) { + try { + localStorage.removeItem(key); + } catch { + // Ignore storage errors. + } + }, + showLoading: function () { // Route transitions are handled by Blazor; avoid full-screen overlays // that block drawer interaction and make the app feel frozen. @@ -326,14 +339,26 @@ window.taxbaikAdminSession = { } window.taxbaikAdminSession.traceUiState('admin-login', 'submit started'); - const response = await fetch('/taxbaik/api/auth/login', { + const loginUrl = new URL('/taxbaik/api/auth/login', window.location.origin).toString(); + const response = await fetch(loginUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }) }); if (!response.ok) { - throw new Error('login failed'); + let errorDetail = ''; + try { + errorDetail = await response.text(); + } catch { + // ignore response body read errors + } + const suffix = errorDetail ? `: ${errorDetail}` : ''; + const error = new Error(`login failed (${response.status} ${response.statusText})${suffix}`); + error.loginStatus = response.status; + error.loginStatusText = response.statusText; + error.loginResponse = errorDetail; + throw error; } const data = await response.json(); @@ -374,7 +399,10 @@ window.taxbaikAdminSession = { component: 'AdminLoginForm', viewportWidth: window.taxbaikAdminSession.getViewportWidth(), userAgent: navigator.userAgent || '', - stack: error?.stack || '' + stack: error?.stack || '', + responseStatus: error?.loginStatus || '', + responseStatusText: error?.loginStatusText || '', + responseBody: (error?.loginResponse || '').slice(0, 500) }); } const errorMessage = document.createElement('div');