From 27319b6ee14ad6ba47c3f0e67b24a142a2d6a214 Mon Sep 17 00:00:00 2001 From: M1CK431 Date: Sun, 13 Aug 2023 23:06:31 +0200 Subject: [PATCH] Webapp > Settings > Security: adapt changePassword call --- src/components/settings/Security.vue | 2 +- src/mixins/socket.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/settings/Security.vue b/src/components/settings/Security.vue index 5d8aed85b3..3d900cee48 100644 --- a/src/components/settings/Security.vue +++ b/src/components/settings/Security.vue @@ -171,7 +171,7 @@ export default { } else { this.$root .getSocket() - .emit("changePassword", this.password, (res) => { + .emit("changePassword", this.$root.userID, this.password, (res) => { this.$root.toastRes(res); if (res.ok) { this.password.currentPassword = ""; diff --git a/src/mixins/socket.js b/src/mixins/socket.js index 3272e042c3..b3afa76071 100644 --- a/src/mixins/socket.js +++ b/src/mixins/socket.js @@ -33,6 +33,7 @@ export default { connectCount: 0, initedSocketIO: false, }, + userID: null, username: null, remember: (localStorage.remember !== "0"), allowLoginDialog: false, // Allowed to show login dialog, but "loggedIn" have to be true too. This exists because prevent the login dialog show 0.1s in first before the socket server auth-ed. @@ -407,8 +408,11 @@ export default { if (res.ok) { this.storage().token = res.token; this.socket.token = res.token; + + const { userID, username } = this.getJWTPayload() || {}; + this.userID = userID; + this.username = username; this.loggedIn = true; - this.username = this.getJWTPayload()?.username; // Trigger Chrome Save Password history.pushState({}, ""); @@ -430,8 +434,10 @@ export default { if (! res.ok) { this.logout(); } else { + const { userID, username } = this.getJWTPayload() || {}; + this.userID = userID; + this.username = username; this.loggedIn = true; - this.username = this.getJWTPayload()?.username; } }); }, @@ -445,6 +451,7 @@ export default { this.storage().removeItem("token"); this.socket.token = null; this.loggedIn = false; + this.userID = null; this.username = null; this.clearData(); },