diff --git a/src/commons/cookie/getUser.ts b/src/commons/cookie/getUser.ts index f7117212..84c1c2c8 100644 --- a/src/commons/cookie/getUser.ts +++ b/src/commons/cookie/getUser.ts @@ -8,6 +8,20 @@ export const getLoginState = () => { return '로그인'; }; +export const validateExpiredToken = () => { + const now = new Date(); + const expiredDate = new Date(getCookie('expiredDate')); + console.log('만료 검사'); + + // 토큰만료 검사 후 삭제 + if (now > expiredDate) { + removeCookie('loginToken'); + removeCookie('expiredDate'); + removeCookie('userAccountInfo'); + console.log('토큰이 만료되어 삭제되었습니다.'); + } +}; + export const removeToken = () => { removeCookie('loginToken'); };