mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-22 04:25:24 +08:00
use auth0/jwt-decode
This commit is contained in:
@@ -414,10 +414,11 @@ import utc from "dayjs/plugin/utc";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import NotificationDialog from "../components/NotificationDialog.vue";
|
||||
import TwoFADialog from "../components/TwoFADialog.vue";
|
||||
import jwt_decode from "jwt-decode";
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
import { timezoneList, setPageLocale, jwtDecrypt } from "../util-frontend";
|
||||
import { timezoneList, setPageLocale } from "../util-frontend";
|
||||
import { useToast } from "vue-toastification";
|
||||
|
||||
const toast = useToast();
|
||||
@@ -488,7 +489,7 @@ export default {
|
||||
|
||||
loadUsername() {
|
||||
const jwtToken = this.$root.storage().token;
|
||||
const jwtPayload = jwtDecrypt(jwtToken);
|
||||
const jwtPayload = jwt_decode(jwtToken);
|
||||
this.username = jwtPayload.username;
|
||||
},
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user