Release v2.1: GDPR, passkeys, session management, admin redesign
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1319,3 +1319,300 @@ body {
|
||||
body.modal-open {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin-shell {
|
||||
display: grid;
|
||||
grid-template-columns: 260px 1fr;
|
||||
min-height: calc(100vh - 72px);
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.admin-sidebar {
|
||||
background: rgba(10, 12, 20, 0.95);
|
||||
border-right: 1px solid var(--border);
|
||||
padding: 24px 16px;
|
||||
position: sticky;
|
||||
top: 72px;
|
||||
height: calc(100vh - 72px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.admin-sidebar__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 24px;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.admin-sidebar__head strong {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.admin-sidebar__head span {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.admin-sidebar__logo {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.admin-sidebar__back {
|
||||
margin-top: auto;
|
||||
padding: 12px 8px;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.admin-main {
|
||||
padding: 28px 32px 48px;
|
||||
}
|
||||
|
||||
.admin-main__header {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.admin-main__title {
|
||||
font-size: 1.75rem;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.admin-main__subtitle {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.admin-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.admin-nav__link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-muted);
|
||||
text-decoration: none;
|
||||
transition: background 0.2s, color 0.2s;
|
||||
}
|
||||
|
||||
.admin-nav__link:hover,
|
||||
.admin-nav__link--active {
|
||||
background: rgba(99, 102, 241, 0.15);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.admin-nav__icon {
|
||||
width: 22px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.admin-stats--cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
gap: 16px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.admin-stat-card {
|
||||
background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(15, 23, 42, 0.8));
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.admin-stat-card--accent {
|
||||
background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(15, 23, 42, 0.8));
|
||||
}
|
||||
|
||||
.admin-stat-card__value {
|
||||
display: block;
|
||||
font-size: 1.75rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.admin-stat-card__label {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.admin-panel--elevated {
|
||||
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.admin-version-bar {
|
||||
margin-bottom: 24px;
|
||||
padding: 12px 16px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.profile-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||
gap: 20px;
|
||||
max-width: 1100px;
|
||||
}
|
||||
|
||||
.profile-card__title {
|
||||
margin-bottom: 8px;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.profile-card__hint,
|
||||
.profile-card__empty {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.session-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.session-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.session-item--current {
|
||||
background: rgba(34, 197, 94, 0.06);
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.session-item__meta {
|
||||
display: block;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.profile-actions {
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.profile-delete-form {
|
||||
margin-top: 20px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.profile-footer {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.legal-section {
|
||||
padding: 48px 0 80px;
|
||||
}
|
||||
|
||||
.legal-container {
|
||||
max-width: 820px;
|
||||
}
|
||||
|
||||
.legal-container h1 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.legal-updated {
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.legal-container h2 {
|
||||
margin: 28px 0 12px;
|
||||
}
|
||||
|
||||
.legal-cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
gap: 16px;
|
||||
margin: 24px 0;
|
||||
}
|
||||
|
||||
.legal-card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.cookie-banner {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1100;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.cookie-banner[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cookie-banner__inner {
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 16px 20px;
|
||||
box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.cookie-banner__text p {
|
||||
margin: 6px 0 0;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.cookie-banner__actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.footer__links {
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
.footer__links a {
|
||||
color: var(--text-muted);
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.admin-shell {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.admin-sidebar {
|
||||
position: static;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.admin-nav {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.cookie-banner__inner {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const banner = document.getElementById("cookieBanner");
|
||||
const acceptBtn = document.getElementById("cookieAcceptBtn");
|
||||
const rejectBtn = document.getElementById("cookieRejectBtn");
|
||||
if (!banner) return;
|
||||
|
||||
const consent = localStorage.getItem("photohost_cookie_consent");
|
||||
if (!consent) {
|
||||
banner.hidden = false;
|
||||
}
|
||||
|
||||
async function saveConsent(analytics) {
|
||||
await fetch("/legal/cookie-consent", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ essential: true, analytics }),
|
||||
});
|
||||
localStorage.setItem("photohost_cookie_consent", analytics ? "all" : "essential");
|
||||
banner.hidden = true;
|
||||
}
|
||||
|
||||
acceptBtn?.addEventListener("click", () => saveConsent(true));
|
||||
rejectBtn?.addEventListener("click", () => saveConsent(false));
|
||||
});
|
||||
@@ -0,0 +1,133 @@
|
||||
function bufferDecode(value) {
|
||||
const padding = "=".repeat((4 - (value.length % 4)) % 4);
|
||||
const base64 = (value + padding).replace(/-/g, "+").replace(/_/g, "/");
|
||||
const raw = window.atob(base64);
|
||||
return Uint8Array.from([...raw].map((c) => c.charCodeAt(0)));
|
||||
}
|
||||
|
||||
function bufferEncode(value) {
|
||||
return btoa(String.fromCharCode(...new Uint8Array(value)))
|
||||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_")
|
||||
.replace(/=+$/, "");
|
||||
}
|
||||
|
||||
async function registerPasskey() {
|
||||
const nameInput = document.getElementById("passkeyName");
|
||||
const name = nameInput ? nameInput.value.trim() : "Passkey";
|
||||
|
||||
const optionsResp = await fetch("/auth/passkey/register/options", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
const options = await optionsResp.json();
|
||||
if (!optionsResp.ok) throw new Error(options.error || "Ошибка passkey");
|
||||
|
||||
options.challenge = bufferDecode(options.challenge);
|
||||
options.user.id = bufferDecode(options.user.id);
|
||||
if (options.excludeCredentials) {
|
||||
options.excludeCredentials = options.excludeCredentials.map((item) => ({
|
||||
...item,
|
||||
id: bufferDecode(item.id),
|
||||
}));
|
||||
}
|
||||
|
||||
const credential = await navigator.credentials.create({ publicKey: options });
|
||||
const verifyResp = await fetch("/auth/passkey/register/verify", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
credential: {
|
||||
id: credential.id,
|
||||
rawId: bufferEncode(credential.rawId),
|
||||
type: credential.type,
|
||||
response: {
|
||||
attestationObject: bufferEncode(credential.response.attestationObject),
|
||||
clientDataJSON: bufferEncode(credential.response.clientDataJSON),
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
const result = await verifyResp.json();
|
||||
if (!verifyResp.ok) throw new Error(result.error || "Не удалось сохранить passkey");
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
async function loginWithPasskey(username, remember) {
|
||||
const optionsResp = await fetch("/auth/passkey/login/options", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username }),
|
||||
});
|
||||
const options = await optionsResp.json();
|
||||
if (!optionsResp.ok) throw new Error(options.error || "Passkey недоступен");
|
||||
|
||||
options.challenge = bufferDecode(options.challenge);
|
||||
if (options.allowCredentials) {
|
||||
options.allowCredentials = options.allowCredentials.map((item) => ({
|
||||
...item,
|
||||
id: bufferDecode(item.id),
|
||||
}));
|
||||
}
|
||||
|
||||
const credential = await navigator.credentials.get({ publicKey: options });
|
||||
const verifyResp = await fetch("/auth/passkey/login/verify", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
remember,
|
||||
credential: {
|
||||
id: credential.id,
|
||||
rawId: bufferEncode(credential.rawId),
|
||||
type: credential.type,
|
||||
response: {
|
||||
authenticatorData: bufferEncode(credential.response.authenticatorData),
|
||||
clientDataJSON: bufferEncode(credential.response.clientDataJSON),
|
||||
signature: bufferEncode(credential.response.signature),
|
||||
userHandle: credential.response.userHandle
|
||||
? bufferEncode(credential.response.userHandle)
|
||||
: null,
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
const result = await verifyResp.json();
|
||||
if (!verifyResp.ok) throw new Error(result.error || "Ошибка входа");
|
||||
window.location.href = result.redirect || "/cabinet/";
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const addBtn = document.getElementById("addPasskeyBtn");
|
||||
if (addBtn) {
|
||||
addBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
if (!window.PublicKeyCredential) {
|
||||
alert("Passkey не поддерживается в этом браузере");
|
||||
return;
|
||||
}
|
||||
await registerPasskey();
|
||||
} catch (err) {
|
||||
alert(err.message || "Ошибка passkey");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const loginBtn = document.getElementById("passkeyLoginBtn");
|
||||
if (loginBtn) {
|
||||
loginBtn.addEventListener("click", async () => {
|
||||
const loginInput = document.getElementById("login");
|
||||
const remember = document.querySelector('input[name="remember"]')?.checked;
|
||||
const username = loginInput ? loginInput.value.trim() : "";
|
||||
if (!username) {
|
||||
alert("Введите логин или email");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await loginWithPasskey(username, remember);
|
||||
} catch (err) {
|
||||
alert(err.message || "Ошибка passkey");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user