Skip to content

Commit

Permalink
hotfix: TokenRefresher 로직 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
pepperdad committed Dec 18, 2024
1 parent f31b001 commit 14b64ab
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/hooks/useTokenRefresher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ export default function TokenRefresher() {
const navigate = useNavigate();
const { openAlert } = useModal();

const user = localStorage.getItem("user");
if (user) {
if (!JSON.parse(user)?.role || !JSON.parse(user)?.refreshToken) {
useEffect(() => {
const user = localStorage.getItem("user");
if (!user || !JSON.parse(user)?.role || !JSON.parse(user)?.refreshToken) {
// 기존에 존재하던 유저 role, refreshToken 유무로 임시로 토큰 제거 후 리로드
localStorage.clear();
openAlert({ title: "다시 로그인 해주세요." });
// window.location.reload();
return <></>;
return;
}
}

useEffect(() => {
const interceptor = instance.interceptors.response.use(
(response) => response,
async (error) => {
Expand Down

0 comments on commit 14b64ab

Please sign in to comment.