fixes
This commit is contained in:
parent
4fc2603818
commit
3f3d8b4eb3
|
@ -417,7 +417,7 @@ import TwoFADialog from "../components/TwoFADialog.vue";
|
||||||
dayjs.extend(utc);
|
dayjs.extend(utc);
|
||||||
dayjs.extend(timezone);
|
dayjs.extend(timezone);
|
||||||
|
|
||||||
import { timezoneList, setPageLocale } from "../util-frontend";
|
import { timezoneList, setPageLocale, jwtDecrypt } from "../util-frontend";
|
||||||
import { useToast } from "vue-toastification";
|
import { useToast } from "vue-toastification";
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
@ -487,11 +487,9 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
loadUsername() {
|
loadUsername() {
|
||||||
const jwtToken = localStorage.getItem("token");
|
const jwtToken = this.$root.storage().token;
|
||||||
const [, payloadBase64] = jwtToken.match(/^\S+\.(\S+)\.\S+$/i);
|
const jwtPayload = jwtDecrypt(jwtToken);
|
||||||
const payload = atob(payloadBase64);
|
this.username = jwtPayload.username;
|
||||||
const oPayload = JSON.parse(payload);
|
|
||||||
this.username = oPayload.username;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
loadSettings() {
|
loadSettings() {
|
||||||
|
|
|
@ -51,7 +51,22 @@ export function timezoneList() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setPageLocale() {
|
export function setPageLocale() {
|
||||||
const html = document.documentElement
|
const html = document.documentElement
|
||||||
html.setAttribute('lang', currentLocale() )
|
html.setAttribute('lang', currentLocale() )
|
||||||
html.setAttribute('dir', localeDirection() )
|
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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue