Merge pull request #772 from andreasbrett/patch-6

show logged in user on settings page
This commit is contained in:
Louis Lam 2021-10-27 10:24:45 +08:00 committed by GitHub
commit 71884cf42a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 2 deletions

11
package-lock.json generated
View file

@ -33,6 +33,7 @@
"http-graceful-shutdown": "~3.1.4", "http-graceful-shutdown": "~3.1.4",
"iconv-lite": "^0.6.3", "iconv-lite": "^0.6.3",
"jsonwebtoken": "~8.5.1", "jsonwebtoken": "~8.5.1",
"jwt-decode": "^3.1.2",
"limiter": "^2.1.0", "limiter": "^2.1.0",
"nodemailer": "~6.6.5", "nodemailer": "~6.6.5",
"notp": "~2.0.3", "notp": "~2.0.3",
@ -7846,6 +7847,11 @@
"safe-buffer": "^5.0.1" "safe-buffer": "^5.0.1"
} }
}, },
"node_modules/jwt-decode": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz",
"integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A=="
},
"node_modules/kind-of": { "node_modules/kind-of": {
"version": "3.2.2", "version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
@ -18495,6 +18501,11 @@
"safe-buffer": "^5.0.1" "safe-buffer": "^5.0.1"
} }
}, },
"jwt-decode": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz",
"integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A=="
},
"kind-of": { "kind-of": {
"version": "3.2.2", "version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",

View file

@ -76,6 +76,7 @@
"http-graceful-shutdown": "~3.1.4", "http-graceful-shutdown": "~3.1.4",
"iconv-lite": "^0.6.3", "iconv-lite": "^0.6.3",
"jsonwebtoken": "~8.5.1", "jsonwebtoken": "~8.5.1",
"jwt-decode": "^3.1.2",
"limiter": "^2.1.0", "limiter": "^2.1.0",
"nodemailer": "~6.6.5", "nodemailer": "~6.6.5",
"notp": "~2.0.3", "notp": "~2.0.3",

View file

@ -304,4 +304,5 @@ export default {
"One record": "Ein Eintrag", "One record": "Ein Eintrag",
"Showing {from} to {to} of {count} records": "Zeige {from} zu {to} von {count} Einträge", "Showing {from} to {to} of {count} records": "Zeige {from} zu {to} von {count} Einträge",
steamApiKeyDescription: "Um einen Steam Game Server zu überwachen, wird ein Steam Web-API-Schlüssel benötigt. Dieser kann hier registriert werden: ", steamApiKeyDescription: "Um einen Steam Game Server zu überwachen, wird ein Steam Web-API-Schlüssel benötigt. Dieser kann hier registriert werden: ",
"Current User": "Aktueller Benutzer",
}; };

View file

@ -306,4 +306,5 @@ export default {
"One record": "One record", "One record": "One record",
"Showing {from} to {to} of {count} records": "Showing {from} to {to} of {count} records", "Showing {from} to {to} of {count} records": "Showing {from} to {to} of {count} records",
steamApiKeyDescription: "For monitoring a Steam Game Server you need a Steam Web-API key. You can register your API key here: ", steamApiKeyDescription: "For monitoring a Steam Game Server you need a Steam Web-API key. You can register your API key here: ",
"Current User": "Current User",
}; };

View file

@ -149,6 +149,7 @@
<!-- Change Password --> <!-- Change Password -->
<template v-if="! settings.disableAuth"> <template v-if="! settings.disableAuth">
<h2 class="mt-5 mb-2">{{ $t("Change Password") }}</h2> <h2 class="mt-5 mb-2">{{ $t("Change Password") }}</h2>
<p>{{ $t("Current User") }}: <strong>{{ this.username }}</strong></p>
<form class="mb-3" @submit.prevent="savePassword"> <form class="mb-3" @submit.prevent="savePassword">
<div class="mb-3"> <div class="mb-3">
<label for="current-password" class="form-label">{{ $t("Current Password") }}</label> <label for="current-password" class="form-label">{{ $t("Current Password") }}</label>
@ -415,6 +416,7 @@ import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone"; import timezone from "dayjs/plugin/timezone";
import NotificationDialog from "../components/NotificationDialog.vue"; import NotificationDialog from "../components/NotificationDialog.vue";
import TwoFADialog from "../components/TwoFADialog.vue"; import TwoFADialog from "../components/TwoFADialog.vue";
import jwt_decode from "jwt-decode";
dayjs.extend(utc); dayjs.extend(utc);
dayjs.extend(timezone); dayjs.extend(timezone);
@ -471,6 +473,7 @@ export default {
}, },
mounted() { mounted() {
this.loadUsername();
this.loadSettings(); this.loadSettings();
this.loadDatabaseSize(); this.loadDatabaseSize();
}, },
@ -497,6 +500,12 @@ export default {
} }
}, },
loadUsername() {
const jwtToken = this.$root.storage().token;
const jwtPayload = jwt_decode(jwtToken);
this.username = jwtPayload.username;
},
loadSettings() { loadSettings() {
this.$root.getSocket().emit("getSettings", (res) => { this.$root.getSocket().emit("getSettings", (res) => {
this.settings = res.data; this.settings = res.data;