From 8016e2976eb48ca00b33ac6f4ce46b164edc364d Mon Sep 17 00:00:00 2001 From: root Date: Fri, 21 Aug 2026 11:18:59 +0000 Subject: [PATCH] =?UTF-8?q?Feature:=20=D0=97=D0=B0=D0=BF=D0=BE=D0=BC=D0=BD?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=BC=D0=B5=D0=BD=D1=8F=20(cookie=2030=20?= =?UTF-8?q?=D0=B4=D0=BD=D0=B5=D0=B9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - HTML: - api.js: loginEmail(email, password, remember) - app.js: emailLogin/register читают флаг и шлют в /auth/login - backend: remember=true → accessTTL=30дн, false → 1ч --- public/index.html | 20 ++++++++++---------- public/js/api.js | 2 +- public/js/app.js | 11 +++++++++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/public/index.html b/public/index.html index d7ca775..c169a0d 100644 --- a/public/index.html +++ b/public/index.html @@ -34,15 +34,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/public/js/api.js b/public/js/api.js index d6b916a..2713351 100644 --- a/public/js/api.js +++ b/public/js/api.js @@ -65,7 +65,7 @@ const Store = { }; const Auth = { - loginEmail: function (email, password) { return apiPost('/api/v1/auth/login', { email: email, password: password }); }, + loginEmail: function (email, password, remember) { return apiPost('/api/v1/auth/login', { email: email, password: password, remember: !!remember }); }, registerEmail: function (data) { return apiPost('/api/v1/auth/register', data); }, me: function () { return apiGet('/api/v1/me'); }, updateMe: function (p) { return apiPut('/api/v1/me', p); }, diff --git a/public/js/app.js b/public/js/app.js index 7086bef..c096a7c 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -212,6 +212,10 @@ const App = { +
Введите email и пароль (≥8 символов)
@@ -300,10 +304,10 @@ const App = { async emailLogin() { const email = document.getElementById('el-email').value.trim(); const pass = document.getElementById('el-pass').value; + const remember = document.getElementById('el-remember')?.checked ?? true; try { - const r = await API.Auth.loginEmail(email, pass); + const r = await API.Auth.loginEmail(email, pass, remember); if (r && r.tokens) API.Store.save(r.tokens); - // same-origin: cookie + body, ничего не висит const me = await API.Auth.me(); API.Store.user = me.user || me; this.onLogin(); @@ -330,12 +334,15 @@ const App = { target.appendChild(ov); try { + const remember = document.getElementById('el-remember')?.checked ?? true; const r = await API.Auth.registerEmail({ email, password: pass, name: email.split('@')[0], consents: { adult: true, terms: true, privacy: true, disclaimer: true }, + remember: remember, }); + if (r && r.tokens) API.Store.save(r.tokens); await API.Auth.me(); ov.remove(); await this.maybeOnboard();