use auth0/jwt-decode

This commit is contained in:
Andreas Brett
2021-10-26 13:15:31 +02:00
parent 3f3d8b4eb3
commit 8fb8cbdaf3
4 changed files with 15 additions and 17 deletions

View File

@@ -55,18 +55,3 @@ export function setPageLocale() {
html.setAttribute('lang', currentLocale() )
html.setAttribute('dir', localeDirection() )
}
export function jwtDecrypt(token) {
const base64Url = token.split(".")[1];
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
const jsonPayload = decodeURIComponent(
atob(base64)
.split("")
.map(function(c) {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
})
.join("")
);
return JSON.parse(jsonPayload);
}