Fix setting page when disabled auth

This commit is contained in:
Louis Lam 2021-11-09 22:37:05 +08:00
parent 733d0af75f
commit 95bae8289d
2 changed files with 17 additions and 4 deletions

View file

@ -1,5 +1,6 @@
import { io } from "socket.io-client";
import { useToast } from "vue-toastification";
import jwt_decode from "jwt-decode";
const toast = useToast();
let socket;
@ -217,6 +218,15 @@ export default {
return (this.remember) ? localStorage : sessionStorage;
},
getJWTPayload() {
const jwtToken = this.$root.storage().token;
if (jwtToken && jwtToken !== "autoLogin") {
return jwt_decode(jwtToken);
}
return undefined;
},
getSocket() {
return socket;
},

View file

@ -515,9 +515,11 @@ export default {
},
loadUsername() {
const jwtToken = this.$root.storage().token;
const jwtPayload = jwt_decode(jwtToken);
this.username = jwtPayload.username;
const jwtPayload = this.$root.getJWTPayload();
if (jwtPayload) {
this.username = jwtPayload.username;
}
},
loadSettings() {
@ -568,6 +570,7 @@ export default {
this.settings.disableAuth = false;
this.saveSettings();
this.$root.storage().removeItem("token");
location.reload();
},
downloadBackup() {