feat: «глазик» в поле пароля при входе и смена своего пароля (сайт — своя карточка, приложение — «Настройки»); Android 1.11.0
This commit is contained in:
@@ -808,6 +808,29 @@ async function peoplePage() {
|
||||
draw();
|
||||
}
|
||||
|
||||
// Смена своего пароля: старый, новый и повтор. Остальные сессии завершаются, эта получает новые токены.
|
||||
function passwordCard() {
|
||||
const inp = ac => h("input", { type: "password", autocomplete: ac });
|
||||
const old = inp("current-password"), nw = inp("new-password"), rep = inp("new-password");
|
||||
const body = h("div", { style: "display:none;margin-top:8px" },
|
||||
h("div", { class: "grid" }, field("Текущий пароль", pwEye(old)), field("Новый пароль", pwEye(nw), "Не короче 10 символов"), field("Новый пароль ещё раз", pwEye(rep))),
|
||||
h("div", { class: "row", style: "margin-top:10px" },
|
||||
h("button", { onclick: guard(async () => {
|
||||
if (!old.value) throw new Error("Введите текущий пароль");
|
||||
if (nw.value.length < 10) throw new Error("Новый пароль — не короче 10 символов");
|
||||
if (nw.value !== rep.value) throw new Error("Новые пароли не совпадают");
|
||||
if (nw.value === old.value) throw new Error("Новый пароль совпадает с текущим");
|
||||
const t = await api("POST", "/auth/change-password", { old_password: old.value, new_password: nw.value });
|
||||
token = t.access_token; localStorage.setItem("token", token); localStorage.setItem("refresh", t.refresh_token);
|
||||
old.value = nw.value = rep.value = ""; body.style.display = "none";
|
||||
toast("Пароль изменён. На других устройствах войдите заново");
|
||||
}) }, "Сменить пароль"),
|
||||
h("button", { class: "sec", onclick: () => { body.style.display = "none"; } }, "Отмена")));
|
||||
return h("div", { class: "card" }, h("div", { class: "row" }, h("h2", { style: "margin:0;flex:1" }, "🔑 Пароль"),
|
||||
h("button", { class: "sec sm", onclick: () => { body.style.display = body.style.display === "none" ? "" : "none"; if (body.style.display === "") old.focus(); } }, "Сменить пароль")),
|
||||
h("div", { class: "small muted", style: "margin-top:4px" }, "После смены пароля вход на других устройствах и в приложении нужно будет выполнить заново."), body);
|
||||
}
|
||||
|
||||
async function userCardPage(id) {
|
||||
const c = await api("GET", `/users/${id}/card`);
|
||||
const u = c.user, reload = () => userCardPage(id);
|
||||
@@ -824,6 +847,7 @@ async function userCardPage(id) {
|
||||
u.department ? h("div", { style: "margin-top:2px" }, "🏢 ", h("a", { href: "#/people?dep=" + u.department.id }, u.department.name)) : null,
|
||||
u.position ? h("div", { class: "small", style: "margin-top:4px" }, u.on_shift ? "🟢 Сейчас на смене" : "⚪ Сейчас не на смене") : null,
|
||||
u.phone && !c.can_edit ? h("div", { style: "margin-top:6px" }, "📞 ", h("a", { href: "tel:" + u.phone.replace(/[^+\d]/g, "") }, u.phone)) : null)),
|
||||
+id === me.id ? passwordCard() : null,
|
||||
h("div", { class: "cols" },
|
||||
h("div", { class: "card" }, h("h2", { style: "margin-top:0" }, "График"),
|
||||
c.schedule.name ? h("div", { class: "small muted", style: "margin-bottom:6px" }, c.schedule.name) : null,
|
||||
|
||||
Reference in New Issue
Block a user