fix(dashboard): api() 헬퍼 사용으로 인증 오류 해결
직접 fetch() + 수동 토큰 조합 대신 tkfb-core.js의 api() 헬퍼 사용. 불필요한 getCookie() 함수 제거. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -48,13 +48,7 @@ function escHtml(s) { const d = document.createElement('div'); d.textContent = s
|
||||
async function initDashboard() {
|
||||
showSkeleton();
|
||||
try {
|
||||
const token = typeof getToken === 'function' ? getToken() : (localStorage.getItem('sso_token') || getCookie('sso_token'));
|
||||
if (!token) { showError('로그인이 필요합니다.'); return; }
|
||||
const resp = await fetch('/api/dashboard/my-summary', {
|
||||
headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' }
|
||||
});
|
||||
if (!resp.ok) throw new Error('API 오류: ' + resp.status);
|
||||
const result = await resp.json();
|
||||
const result = await api('/dashboard/my-summary');
|
||||
if (!result.success) throw new Error(result.message || '데이터 로드 실패');
|
||||
renderDashboard(result.data);
|
||||
} catch (err) {
|
||||
@@ -62,11 +56,6 @@ async function initDashboard() {
|
||||
}
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
const v = document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)');
|
||||
return v ? v.pop() : '';
|
||||
}
|
||||
|
||||
function renderDashboard(data) {
|
||||
const { user, vacation, overtime, quick_access } = data;
|
||||
|
||||
|
||||
@@ -34,6 +34,6 @@
|
||||
</main>
|
||||
|
||||
<script src="/static/js/tkfb-core.js?v=2026033002"></script>
|
||||
<script src="/js/production-dashboard.js?v=2026033001"></script>
|
||||
<script src="/js/production-dashboard.js?v=2026033002"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user