⇒ 로컬에서 단순 사용자 정보를 판단하기때문에, 토큰의 만료 유무는 검증하지 않습니다. 그렇기에 토큰의 만료 시간 검증이 필요하다면, 직접 구현해야합니다.
function isTokenExpired(token) {
if (!token) return true;
try {
const payload = JSON.parse(atob(token.split('.')[1]));
const now = Math.floor(Date.now() / 1000); // 현재 시간(초)
return payload.exp < now;
} catch (e) {
// 토큰 파싱 실패 시 만료로 간주
return true;
}
}