mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-24 06:49:41 -05:00
use jwt
This commit is contained in:
parent
4becb97a5d
commit
9ddd2c7365
@ -894,26 +894,6 @@ exports.entryPage = "dashboard";
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("getUsername", async (callback) => {
|
|
||||||
try {
|
|
||||||
checkLogin(socket);
|
|
||||||
|
|
||||||
let user = await R.findOne("user", " id = ? AND active = 1 ", [
|
|
||||||
socket.userID,
|
|
||||||
]);
|
|
||||||
|
|
||||||
callback({
|
|
||||||
ok: true,
|
|
||||||
data: user.username,
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
callback({
|
|
||||||
ok: false,
|
|
||||||
msg: e.message,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on("getSettings", async (callback) => {
|
socket.on("getSettings", async (callback) => {
|
||||||
try {
|
try {
|
||||||
checkLogin(socket);
|
checkLogin(socket);
|
||||||
|
@ -487,9 +487,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadUsername() {
|
loadUsername() {
|
||||||
this.$root.getSocket().emit("getUsername", (res) => {
|
const jwtToken = localStorage.getItem("token");
|
||||||
this.username = res.data;
|
const [match, headerBase64, payloadBase64, signatureBase64] = jwtToken.match(/^(\S+)\.(\S+)\.(\S+)$/i);
|
||||||
});
|
const payload = atob(payloadBase64);
|
||||||
|
const oPayload = JSON.parse(payload);
|
||||||
|
this.username = oPayload.username;
|
||||||
},
|
},
|
||||||
|
|
||||||
loadSettings() {
|
loadSettings() {
|
||||||
|
Loading…
Reference in New Issue
Block a user