upd
This commit is contained in:
@@ -211,7 +211,7 @@
|
||||
<div id="users-list" class="flex flex-col gap-2"></div>
|
||||
</div>
|
||||
<!-- Смена своего пароля -->
|
||||
<div class="px-5 py-4 border-t border-gray-800">
|
||||
<div id="chpwd-section" class="px-5 py-4 border-t border-gray-800">
|
||||
<h3 class="text-sm font-semibold text-gray-300 uppercase tracking-wider mb-3">Сменить пароль</h3>
|
||||
<div class="flex flex-col gap-2 max-w-sm">
|
||||
<input id="chpwd-new" type="password" placeholder="Новый пароль"
|
||||
@@ -234,7 +234,7 @@
|
||||
<label class="text-xs text-gray-400 mb-1 block">Логин</label>
|
||||
<input id="user-modal-username" type="text" class="w-full px-3 py-2 rounded-lg text-sm text-white border border-gray-700 focus:border-indigo-500 outline-none" style="background:#0f1117" placeholder="username">
|
||||
</div>
|
||||
<div>
|
||||
<div id="user-modal-pwd-wrap">
|
||||
<label class="text-xs text-gray-400 mb-1 block">Пароль <span id="user-modal-pwd-hint" class="text-gray-600">(оставьте пустым чтобы не менять)</span></label>
|
||||
<input id="user-modal-password" type="password" class="w-full px-3 py-2 rounded-lg text-sm text-white border border-gray-700 focus:border-indigo-500 outline-none" style="background:#0f1117" placeholder="••••••">
|
||||
</div>
|
||||
@@ -391,13 +391,14 @@ function showLoginScreen() {
|
||||
function hideLoginScreen() {
|
||||
document.getElementById('login-screen').classList.add('hidden');
|
||||
document.getElementById('logout-btn').classList.remove('hidden');
|
||||
// Обновляем отображение текущего пользователя в хедере
|
||||
const uinfo = document.getElementById('user-info');
|
||||
if(uinfo && state.currentUser) {
|
||||
const roleLabel = state.currentUser.role === 'admin' ? '👑' : '👤';
|
||||
uinfo.textContent = `${roleLabel} ${state.currentUser.username}`;
|
||||
uinfo.classList.remove('hidden');
|
||||
}
|
||||
const chpwd = document.getElementById('chpwd-section');
|
||||
if(chpwd) chpwd.classList.toggle('hidden', !!(state.currentUser && state.currentUser.is_env_admin));
|
||||
}
|
||||
|
||||
async function checkAuth() {
|
||||
@@ -766,7 +767,7 @@ function switchTab(tab) {
|
||||
document.getElementById('manga-filters').classList.toggle('hidden', tab !== 'mangas');
|
||||
if(tab === 'history') loadHistory();
|
||||
if(tab === 'news') { newsUnreadCount = 0; updateNewsBadge(); loadNews(); }
|
||||
if(tab === 'settings') loadSources();
|
||||
if(tab === 'settings') { loadSources(); showUsersSection(); }
|
||||
}
|
||||
|
||||
function updateNewsBadge() {
|
||||
@@ -1110,11 +1111,12 @@ function renderUsers(users) {
|
||||
<span class="text-xs px-2 py-0.5 rounded-full font-semibold" style="${roleColors[u.role] || ''}">
|
||||
${u.role === 'admin' ? '👑 admin' : '👤 user'}
|
||||
</span>
|
||||
${u.is_env_admin ? '<span class="text-xs text-gray-500" title="Системный администратор — пароль задаётся через AUTH_PASSWORD">🔒</span>' : ''}
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button onclick="openEditUserModal(${u.id}, '${escHtml(u.username)}', '${u.role}')"
|
||||
<button onclick="openEditUserModal(${u.id}, '${escHtml(u.username)}', '${u.role}', ${!!u.is_env_admin})"
|
||||
class="text-xs px-2 py-1 rounded text-gray-400 hover:text-white" style="background:#334155">✏️</button>
|
||||
${u.id !== state.currentUser?.id ? `<button onclick="confirmDeleteUser(${u.id}, '${escHtml(u.username)}')"
|
||||
${!u.is_env_admin && u.id !== state.currentUser?.id ? `<button onclick="confirmDeleteUser(${u.id}, '${escHtml(u.username)}')"
|
||||
class="text-xs px-2 py-1 rounded text-red-400 hover:text-red-300" style="background:#2d1111">✕</button>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1127,6 +1129,8 @@ function openAddUserModal() {
|
||||
document.getElementById('user-modal-username').value = '';
|
||||
document.getElementById('user-modal-username').disabled = false;
|
||||
document.getElementById('user-modal-password').value = '';
|
||||
const pwdWrap = document.getElementById('user-modal-pwd-wrap');
|
||||
if(pwdWrap) pwdWrap.style.display = '';
|
||||
document.getElementById('user-modal-pwd-hint').style.display = 'none';
|
||||
document.getElementById('user-modal-role').value = 'user';
|
||||
document.getElementById('user-modal-error').classList.add('hidden');
|
||||
@@ -1134,13 +1138,19 @@ function openAddUserModal() {
|
||||
document.getElementById('user-modal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function openEditUserModal(id, username, role) {
|
||||
function openEditUserModal(id, username, role, isEnvAdmin) {
|
||||
_userModalEditId = id;
|
||||
document.getElementById('user-modal-title').textContent = 'Редактировать пользователя';
|
||||
document.getElementById('user-modal-username').value = username;
|
||||
document.getElementById('user-modal-username').disabled = false;
|
||||
document.getElementById('user-modal-password').value = '';
|
||||
document.getElementById('user-modal-pwd-hint').style.display = '';
|
||||
const pwdWrap = document.getElementById('user-modal-pwd-wrap');
|
||||
if(isEnvAdmin) {
|
||||
if(pwdWrap) pwdWrap.style.display = 'none';
|
||||
} else {
|
||||
if(pwdWrap) pwdWrap.style.display = '';
|
||||
document.getElementById('user-modal-pwd-hint').style.display = '';
|
||||
}
|
||||
document.getElementById('user-modal-role').value = role;
|
||||
document.getElementById('user-modal-error').classList.add('hidden');
|
||||
document.getElementById('user-modal').style.display = 'flex';
|
||||
|
||||
Reference in New Issue
Block a user