

250609 김혜민 로그아웃 세션 및 토큰제거 수정 2
@df503a9b46a4a5922411f512786bb0814925e56c
--- client/views/pages/AppStore.js
+++ client/views/pages/AppStore.js
... | ... | @@ -124,7 +124,6 @@ |
124 | 124 |
}, |
125 | 125 |
actions: { |
126 | 126 |
async logout({ commit, state, dispatch }) { |
127 |
- console.log('로그아웃 프로세스 시작'); |
|
128 | 127 |
|
129 | 128 |
const ctx = state.contextPath; |
130 | 129 |
const admPath = state.path?.includes("/adm"); |
... | ... | @@ -132,68 +131,38 @@ |
132 | 131 |
|
133 | 132 |
try { |
134 | 133 |
// 1. 서버 로그아웃 API 호출 (모든 모드에서 호출) |
135 |
- try { |
|
136 | 134 |
const res = await logOutProc(); |
137 |
- console.log('서버 로그아웃 응답:', res); |
|
138 |
- |
|
139 |
- if (res?.data?.message) { |
|
140 |
- console.log('로그아웃 메시지:', res.data.message); |
|
141 |
- } |
|
142 |
- } catch (apiError) { |
|
143 |
- // API 호출 실패해도 클라이언트 정리는 계속 진행 |
|
144 |
- console.warn('서버 로그아웃 API 호출 실패:', apiError.message); |
|
145 |
- } |
|
146 |
- |
|
147 | 135 |
// 2. 클라이언트 완전 정리 |
148 | 136 |
await dispatch('performCompleteCleanup', { loginMode, ctx, admPath }); |
149 |
- |
|
150 | 137 |
} catch (error) { |
151 |
- console.error("로그아웃 처리 중 오류:", error); |
|
152 |
- |
|
153 | 138 |
// 오류 발생해도 클라이언트 정리는 수행 |
154 | 139 |
await dispatch('performCompleteCleanup', { loginMode, ctx, admPath }); |
155 |
- |
|
156 |
- // 사용자에게는 간단한 메시지만 표시 |
|
157 |
- console.log("로그아웃 처리가 완료되었습니다."); |
|
158 | 140 |
} |
159 | 141 |
}, |
160 | 142 |
|
161 | 143 |
// 완전한 클라이언트 정리 수행 |
162 | 144 |
async performCompleteCleanup({ commit, dispatch }, { loginMode, ctx, admPath }) { |
163 | 145 |
try { |
164 |
- console.log('클라이언트 정리 시작'); |
|
165 |
- |
|
166 | 146 |
// 1. 상태 초기화 |
167 | 147 |
commit("setStoreReset"); |
168 |
- |
|
169 | 148 |
// 2. 모든 저장소 완전 정리 |
170 | 149 |
dispatch('clearAllStorages'); |
171 |
- |
|
172 | 150 |
// 3. 모든 쿠키 제거 |
173 | 151 |
dispatch('clearAllCookies'); |
174 |
- |
|
175 | 152 |
// 4. 세션 무효화 (세션 모드인 경우) |
176 | 153 |
if (loginMode === 'S') { |
177 | 154 |
dispatch('invalidateSession'); |
178 | 155 |
} |
179 |
- |
|
180 | 156 |
// 5. 브라우저 캐시 정리 |
181 | 157 |
dispatch('clearBrowserCache'); |
182 |
- |
|
183 | 158 |
// 6. 페이지 리다이렉트 |
184 | 159 |
const loginUrl = admPath ? |
185 | 160 |
(ctx || '') + "/cmslogin.page" : |
186 | 161 |
(ctx || '') + "/login.page"; |
187 |
- |
|
188 |
- console.log('로그인 페이지로 이동:', loginUrl); |
|
189 |
- |
|
190 | 162 |
// 히스토리 정리 후 이동 |
191 | 163 |
window.history.replaceState(null, '', loginUrl); |
192 | 164 |
window.location.href = loginUrl; |
193 |
- |
|
194 | 165 |
} catch (cleanupError) { |
195 |
- console.error('클라이언트 정리 중 오류:', cleanupError); |
|
196 |
- |
|
197 | 166 |
// 최종 수단: 강제 새로고침 |
198 | 167 |
window.location.reload(); |
199 | 168 |
} |
... | ... | @@ -201,7 +170,6 @@ |
201 | 170 |
|
202 | 171 |
// 모든 저장소 정리 |
203 | 172 |
clearAllStorages() { |
204 |
- try { |
|
205 | 173 |
// localStorage 완전 정리 |
206 | 174 |
const localStorageKeys = Object.keys(localStorage); |
207 | 175 |
localStorageKeys.forEach(key => { |
... | ... | @@ -215,16 +183,10 @@ |
215 | 183 |
sessionStorage.removeItem(key); |
216 | 184 |
}); |
217 | 185 |
sessionStorage.clear(); |
218 |
- |
|
219 |
- console.log('모든 저장소 정리 완료'); |
|
220 |
- } catch (error) { |
|
221 |
- console.error('저장소 정리 중 오류:', error); |
|
222 |
- } |
|
223 | 186 |
}, |
224 | 187 |
|
225 | 188 |
// 모든 쿠키 제거 |
226 | 189 |
clearAllCookies() { |
227 |
- try { |
|
228 | 190 |
const cookiesToDelete = [ |
229 | 191 |
// 일반 인증 쿠키 |
230 | 192 |
'refresh', |
... | ... | @@ -286,30 +248,19 @@ |
286 | 248 |
}); |
287 | 249 |
}); |
288 | 250 |
}); |
289 |
- |
|
290 |
- console.log('모든 쿠키 제거 완료'); |
|
291 |
- } catch (error) { |
|
292 |
- console.error('쿠키 제거 중 오류:', error); |
|
293 |
- } |
|
294 | 251 |
}, |
295 | 252 |
|
296 | 253 |
// 세션 무효화 |
297 | 254 |
invalidateSession() { |
298 |
- try { |
|
299 | 255 |
// 세션 무효화를 위한 더미 요청 (필요한 경우) |
300 | 256 |
fetch('/mbr/sessionInvalidate', { |
301 | 257 |
method: 'POST', |
302 | 258 |
credentials: 'include' |
303 | 259 |
}).catch(() => {}); // 실패해도 무시 |
304 |
- |
|
305 |
- } catch (error) { |
|
306 |
- console.error('세션 무효화 중 오류:', error); |
|
307 |
- } |
|
308 | 260 |
}, |
309 | 261 |
|
310 | 262 |
// 브라우저 캐시 정리 |
311 | 263 |
clearBrowserCache() { |
312 |
- try { |
|
313 | 264 |
// 캐시 API 지원 확인 및 정리 |
314 | 265 |
if ('caches' in window) { |
315 | 266 |
caches.keys().then(cacheNames => { |
... | ... | @@ -329,10 +280,6 @@ |
329 | 280 |
} catch (e) {} |
330 | 281 |
}); |
331 | 282 |
} |
332 |
- |
|
333 |
- } catch (error) { |
|
334 |
- console.error('브라우저 캐시 정리 중 오류:', error); |
|
335 |
- } |
|
336 | 283 |
}, |
337 | 284 |
|
338 | 285 |
setUserType({ commit }, userType) { |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?