mirror of
https://github.com/andrey271192/PCAtelegram_web.git
synced 2026-09-21 12:01:56 +00:00
feat: add branded login and editable admin credentials
This commit is contained in:
@@ -100,6 +100,12 @@ const i18n = {
|
||||
panelLanguage: "Panel language",
|
||||
theme: "Theme",
|
||||
bindAddress: "Bind address",
|
||||
authSettingsTitle: "Login credentials",
|
||||
authCurrentPassword: "Current password",
|
||||
authUsername: "Username",
|
||||
authNewPassword: "New password",
|
||||
authSave: "Save login",
|
||||
authSaved: "Login updated",
|
||||
dashboard: "Dashboard",
|
||||
noKeys: "No keys yet",
|
||||
noBackups: "No backups yet",
|
||||
@@ -327,6 +333,12 @@ const i18n = {
|
||||
panelLanguage: "Язык панели",
|
||||
theme: "Тема",
|
||||
bindAddress: "Адрес привязки",
|
||||
authSettingsTitle: "Данные входа",
|
||||
authCurrentPassword: "Текущий пароль",
|
||||
authUsername: "Логин",
|
||||
authNewPassword: "Новый пароль",
|
||||
authSave: "Сохранить вход",
|
||||
authSaved: "Данные входа обновлены",
|
||||
dashboard: "Обзор",
|
||||
noKeys: "Ключей пока нет",
|
||||
noBackups: "Бекапов пока нет",
|
||||
@@ -636,6 +648,31 @@ async function setLanguage(lang) {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateAuthSettings(eventObj) {
|
||||
eventObj.preventDefault();
|
||||
const form = eventObj.currentTarget;
|
||||
const btn = form.querySelector("button[type='submit']");
|
||||
const body = {
|
||||
current_password: form.current_password.value,
|
||||
username: form.username.value.trim(),
|
||||
new_password: form.new_password.value,
|
||||
};
|
||||
btn.disabled = true;
|
||||
try {
|
||||
await api("/api/settings/auth", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
form.current_password.value = "";
|
||||
form.new_password.value = "";
|
||||
toast(t("authSaved"));
|
||||
} catch (err) {
|
||||
toast(err.message);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function setPage(page, push = true) {
|
||||
const next = $(`[data-page="${page}"]`) ? page : "dashboard";
|
||||
state.page = next;
|
||||
@@ -1744,6 +1781,7 @@ $("#createBackupBtn").addEventListener("click", createBackup);
|
||||
$("#loadLogsBtn").addEventListener("click", loadLogs);
|
||||
$("#repairStatsBtn").addEventListener("click", repairStats);
|
||||
$("#collectStatsBtn").addEventListener("click", collectStats);
|
||||
$("#authSettingsForm").addEventListener("submit", updateAuthSettings);
|
||||
window.addEventListener("hashchange", () => setPage((location.hash || "#dashboard").slice(1), false));
|
||||
|
||||
setPage((location.hash || "#dashboard").slice(1), false);
|
||||
|
||||
Reference in New Issue
Block a user