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();