fix: expose manager account and password controls

This commit is contained in:
pavlov346346-source 2026-09-12 10:10:25 +03:00
parent f0629ba1a4
commit bd7995d68c

View File

@ -1,7 +1,7 @@
(()=>{
'use strict';
if(window.CateriumAccountCenterV1780)return;
const VERSION='17.8.0-account-center-v2';
const VERSION='17.8.0-account-center-v3';
const $=(s,r=document)=>r.querySelector(s);
const qa=(s,r=document)=>[...r.querySelectorAll(s)];
const esc=v=>window.SunSafe?.escapeHTML?window.SunSafe.escapeHTML(String(v??'')):String(v??'');
@ -42,6 +42,7 @@ function installStyle(){
#cateriumAccountCenter .cac-company-actions{display:flex;gap:10px;flex-wrap:wrap}
#sunCurrentUserLabel{cursor:pointer}
#sunCurrentUserLabel:hover{text-decoration:underline;text-underline-offset:3px}
#cateriumAccountButton{display:flex!important}
#sun-cloud-users-modal [data-caterium-owner-row="1"]{background:#fff9e8;border:1px solid #ead39a;border-radius:10px;padding:10px}
#sun-cloud-users-modal .caterium-owner-chip{display:inline-flex;align-items:center;border-radius:999px;background:#f4dfad;color:#6d5118;padding:5px 9px;font-size:11px;font-weight:900}
@media(max-width:720px){#cateriumAccountCenter{padding:0;place-items:stretch}#cateriumAccountCenter .cac-shell{width:100%;max-height:none;height:100dvh;border-radius:0}#cateriumAccountCenter .cac-grid{grid-template-columns:1fr}#cateriumAccountCenter .cac-card.wide{grid-column:auto}#cateriumAccountCenter .cac-head,#cateriumAccountCenter .cac-body{padding-left:18px;padding-right:18px}}
@ -80,10 +81,11 @@ function render(){
<div class="cac-note">На новый адрес придёт письмо подтверждения.</div>
</section>
<section class="cac-card">
<h3>Пароль</h3>
<h3>Смена пароля</h3>
<label>Новый пароль<input id="cacPassword" type="password" autocomplete="new-password" minlength="8"></label>
<label>Повторите пароль<input id="cacPassword2" type="password" autocomplete="new-password" minlength="8"></label>
<div class="cac-actions"><button class="primary" id="cacSavePassword" type="button">Сменить пароль</button></div>
<div class="cac-note">Пароль меняется только для вашего аккаунта. Администратор компании его не видит.</div>
</section>
${owner?`<section class="cac-card"><h3>Компания и пользователи</h3><p class="cac-note">Создавайте сотрудников, назначайте им рабочую роль и включайте только нужные права.</p><div class="cac-company-actions"><button class="primary" id="cacOpenUsers" type="button">Пользователи и права</button></div></section>`:''}
<section class="cac-card wide"><h3>Сеанс</h3><div class="cac-actions"><button class="outline" id="cacLogout" type="button">Выйти из аккаунта</button></div></section>
@ -125,10 +127,21 @@ function sanitizeRbac(){
}
const addRole=$('#sunRbacEmployeeRole',body);if(addRole)qa('option[value="admin"]',addRole).forEach(o=>o.remove());
}
function ensureSidebarEntry(){
const footer=$('.sun-side-footer');if(!footer||!session()?.user)return;
let button=$('#cateriumAccountButton');
if(!button){
button=document.createElement('button');
button.id='cateriumAccountButton';button.type='button';button.className='sun-side-action';button.title='Профиль, email и пароль';
button.innerHTML='<span>◎</span><span>Мой аккаунт</span>';
footer.insertBefore(button,footer.querySelector('#sunLogoutBtn')||footer.firstChild);
}
if(!button.dataset.cateriumAccountBound){button.dataset.cateriumAccountBound='1';button.addEventListener('click',open)}
}
function bindEntry(){
const label=$('#sunCurrentUserLabel');if(label&&!label.dataset.cateriumAccountBound){label.dataset.cateriumAccountBound='1';label.title='Открыть личный кабинет';label.addEventListener('click',open)}
const ss=session();const uid=ss?.user?.id||'';if(uid&&uid!==lastUserId){lastUserId=uid;snapshot=null;}
sanitizeRbac();
ensureSidebarEntry();sanitizeRbac();
}
installStyle();ensureModal();bindEntry();
const obs=new MutationObserver(bindEntry);obs.observe(document.documentElement,{childList:true,subtree:true});