Skip to content

Commit

Permalink
🔀 Refactor/editTokenLogic#305 [토큰 만료시 자동 로그아웃 구현 등]
Browse files Browse the repository at this point in the history
#305 토큰 만료시 자동로그아웃 구현 완료
  • Loading branch information
Herrypi authored Nov 10, 2024
2 parents 936fb73 + 1268f84 commit c899288
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 15 deletions.
6 changes: 3 additions & 3 deletions gongjakso/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
gtag('config', 'G-757LG6FY1Q');
</script>
<!-- HTML Meta Tags -->
<title>공작소</title>
<title>공모전 팀빌딩 서비스 | 공작소 gongjakso</title>
<meta name="description" content="귀찮은 공모전 팀 구인 과정은 이제 그만! 내가 원하는 조건에 맞추어 공모전 팀원을 모집해보세요.">

<!-- Facebook Meta Tags -->
<meta property="og:url" content="https://gongjakso.xyz">
<meta property="og:type" content="website">
<meta property="og:title" content="공작소">
<meta property="og:title" content="공모전 팀빌딩 서비스 | 공작소 gongjakso">
<meta property="og:description" content="귀찮은 공모전 팀 구인 과정은 이제 그만! 내가 원하는 조건에 맞추어 공모전 팀원을 모집해보세요.">
<meta property="og:image" content="https://opengraph.b-cdn.net/production/images/5585fb04-c501-4717-8122-8c9d3d05f246.png?token=hOfHzJ7eKbz1nuru47epxsiWBHDGHpfIodgv5PB7b0Y&height=557&width=1200&expires=33266696940">

<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="gongjakso.xyz">
<meta property="twitter:url" content="https://gongjakso.xyz">
<meta name="twitter:title" content="공작소">
<meta name="twitter:title" content="공모전 팀빌딩 서비스 | 공작소 gongjakso">
<meta name="twitter:description" content="귀찮은 공모전 팀 구인 과정은 이제 그만! 내가 원하는 조건에 맞추어 공모전 팀원을 모집해보세요.">
<meta name="twitter:image" content="https://opengraph.b-cdn.net/production/images/5585fb04-c501-4717-8122-8c9d3d05f246.png?token=hOfHzJ7eKbz1nuru47epxsiWBHDGHpfIodgv5PB7b0Y&height=557&width=1200&expires=33266696940">

Expand Down
1 change: 1 addition & 0 deletions gongjakso/src/components/common/CountGuest/CountGuest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const CountGuest = ({ isProject, maxGuests, onApply }) => {
const [roles, setRoles] = useState({
기획: 0,
디자인: 0,
개발자: 0,
...(isProject && { FE: 0, BE: 0 }),
기타: 0,
});
Expand Down
7 changes: 6 additions & 1 deletion gongjakso/src/pages/ProfilePage/ProfilePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const MAX_PORTFOLIOS = 3;

const ProfilePage = () => {
const [data, setProfileData] = useState();
const authenticated = localStorage.getItem('accessToken');
const [isLoggedIn, setIsLoggedIn] = useState(!!authenticated);
const [postContent1, setPostContent1] = useState();
const [postContent2, setPostContent2] = useState();
const [postContent3, setPostContent3] = useState();
Expand All @@ -37,6 +39,9 @@ const ProfilePage = () => {
const [portfolioList, setPortfolioList] = useState([]);

useEffect(() => {
if (!isLoggedIn) {
navigate(`/`);
}
getMyInfo().then(response => {
setProfileData(response?.data);
});
Expand All @@ -49,7 +54,7 @@ const ProfilePage = () => {
getMyParticipated(1, 2).then(response => {
setPostContent3(response?.data?.content);
});
}, []);
}, [isLoggedIn]);
useEffect(() => {
if (selectedPortfolioId && selectedPortfolioType) {
fetchPortfolioDetailsByType(
Expand Down
12 changes: 9 additions & 3 deletions gongjakso/src/service/portfolio_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export const getAllPortfolio = async () => {
const response = await axiosInstanceV2.get(reqURL);
return response;
} catch (error) {
console.log(error);
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
return error.response.data.code;
}
};
Expand Down Expand Up @@ -49,7 +51,9 @@ export const getPortfolio = async id => {
const response = await axiosInstanceV2.get(reqURL);
return response;
} catch (error) {
console.log(error);
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
return error.response?.data.code;
}
};
Expand All @@ -62,7 +66,9 @@ export const getExistPortfolio = async (id, type) => {
const response = await axiosInstanceV2.get(reqURL);
return response;
} catch (error) {
console.log('Error getting portfolio details:', error);
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
return error.response.data.code;
}
};
Expand Down
4 changes: 3 additions & 1 deletion gongjakso/src/service/post_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export const getMyPortfolio = async () => {
const response = await axiosInstanceV2.get(reqURL);
return response.data;
} catch (error) {
console.log(error);
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
}
};

Expand Down
29 changes: 22 additions & 7 deletions gongjakso/src/service/profile_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const putMyInfo = async (name, major, job, status, phone) => {
});
return response.data;
} catch (error) {
console.log(error);
throw new Error('나의 정보를 가져올 수 없습니다.');
}
};
Expand All @@ -25,7 +26,9 @@ export const getMyInfo = async () => {
const response = await axiosInstance.get(reqURL);
return response.data;
} catch (error) {
console.log('내가 지원한 게시글을 가져올 수 없습니다.');
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
}
};

Expand All @@ -37,7 +40,9 @@ export const getMyRecruiting = async (page, size) => {
const response = await axiosInstanceV2.get(reqURL);
return response.data;
} catch (error) {
console.log('내가 모집 중인 게시글을 가져올 수 없습니다.', error);
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
}
};

Expand All @@ -49,7 +54,9 @@ export const getMyApplied = async page => {
const response = await axiosInstanceV2.get(reqURL);
return response.data;
} catch (error) {
console.log('내가 지원한 게시글을 가져올 수 없습니다.');
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
}
};

Expand All @@ -62,7 +69,9 @@ export const getMyParticipated = async (page, size) => {
const response = await axiosInstanceV2.get(reqURL);
return response.data;
} catch (error) {
console.log(error);
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
}
};

Expand All @@ -72,7 +81,9 @@ export const getMyContestScrap = async () => {
const response = await axiosInstance.get(reqURL);
return response.data;
} catch (error) {
console.log('내가 스크랩한 공모전 정보를 가져올 수 없습니다.');
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
}
};

Expand All @@ -82,7 +93,9 @@ export const getMyProjectScrap = async () => {
const response = await axiosInstance.get(reqURL);
return response.data;
} catch (error) {
console.log('내가 스크랩한 프로젝트 정보를 가져올 수 없습니다.');
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
}
};
export const getMyTeamScrap = async (page, size) => {
Expand All @@ -91,6 +104,8 @@ export const getMyTeamScrap = async (page, size) => {
const response = await axiosInstanceV2.get(reqURL);
return response.data;
} catch (error) {
console.log('내가 스크랩한 프로젝트 정보를 가져올 수 없습니다.');
error.response.data.code = 3004
? localStorage.removeItem('accessToken')
: console.log(error.response.data.message);
}
};

0 comments on commit c899288

Please sign in to comment.