From f01f0026143ed1098d92bb2521687dc9e5ef4796 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Thu, 7 May 2026 14:16:26 +0900 Subject: [PATCH] =?UTF-8?q?refactor(account):=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=83=81=ED=83=9C=20=ED=95=84=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A6=AC=20=EB=B0=8F=20role=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 왜: userId/nickname/profileImage는 사용처가 없어 유지보수 단순화. 대신 권한 판별을 위해 role 필요.\n무엇: accountStore에서 세 필드 삭제, role 추가. isAuthenticated 동기화 수정. LOGIN/LOGOUT 로직 role 반영. Axios Authorization 유지. --- src/store/accountStore.js | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/store/accountStore.js b/src/store/accountStore.js index de53132..8929013 100644 --- a/src/store/accountStore.js +++ b/src/store/accountStore.js @@ -12,17 +12,13 @@ enhanceAccessToken(); const accountStore = { namespaced: true, state: { - userId: '', - nickname: '', accessToken: '', - profileImage: '', + role: '', }, getters: { isAuthenticated(state) { - state.userId = state.userId || localStorage.userId - state.nickname = state.nickname || localStorage.nickname - state.profileImage = state.profileImage || localStorage.profileImage state.accessToken = state.accessToken || localStorage.accessToken + state.role = state.role || localStorage.role return state.accessToken !== undefined && state.accessToken !== null && @@ -31,27 +27,19 @@ const accountStore = { } }, mutations: { - LOGIN(state, {userId, nickname, token, profileImage}) { - state.userId = userId - localStorage.userId = userId - - state.nickname = nickname - localStorage.nickname = nickname - - state.profileImage = profileImage - localStorage.profileImage = profileImage - + LOGIN(state, {token, role}) { state.accessToken = token localStorage.accessToken = token + state.role = role + localStorage.role = role + Vue.axios.defaults.headers.common['Authorization'] = `Bearer ${token}`; }, LOGOUT(state) { - state.userId = '' - state.nickname = '' - state.profileImage = '' state.accessToken = '' + state.role = '' localStorage.clear() if (location.pathname === '/') {