web/plugins/ParseJwt/page.jsx

19 lines
393 B
React
Raw Permalink Normal View History

2023-12-12 14:51:25 +03:30
const ParseJwt = (token) => {
// const router = useRouter();
try {
if (!token) {
return;
}
const base64Url = token.split(".")[1];
const base64 = base64Url.replace("-", "+").replace("_", "/");
return JSON.parse(window.atob(base64));
} catch (error) {
localStorage.removeItem("token");
window.location.reload("/login");
2023-10-19 11:44:56 +03:30
}
2023-12-12 14:51:25 +03:30
};
export default ParseJwt;