Files
playwish/server/app/static/login.js
T
99admandClaude Opus 5.5 3610de7bae Audiofy – Musikwünsche für Partys
Server (Website, Admin-Bereich, Player-API) und Player (raspotify +
Controller) mit Install-Skripten für Debian-Systeme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 19:16:39 +01:00

36 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Audiofy – Admin-Login
"use strict";
let schutz = { token: async () => null, reset() {}, bereit: () => true }; // Turnstile (falls aktiv)
window.AudiofyTurnstile.einrichten(document.getElementById("turnstile"), "login").then((s) => { schutz = s; });
document.getElementById("login").addEventListener("submit", async (ereignis) => {
ereignis.preventDefault();
const fehler = document.getElementById("fehler");
const knopf = ereignis.target.querySelector("button");
fehler.textContent = "";
knopf.disabled = true;
try {
if (!schutz.bereit()) knopf.textContent = "Sicherheitsprüfung …";
const turnstile = await schutz.token();
knopf.textContent = "Anmelden …";
const antwort = await fetch("/admin/login", {
method: "POST",
credentials: "same-origin",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password: document.getElementById("passwort").value, turnstile }),
}).finally(() => schutz.reset());
if (antwort.ok) {
location.href = "/admin";
return;
}
let meldung = "Anmeldung fehlgeschlagen.";
try { meldung = (await antwort.json()).detail || meldung; } catch (_) { /* leer */ }
fehler.textContent = meldung;
} catch (_) {
fehler.textContent = "Keine Verbindung zum Server.";
}
knopf.textContent = "Anmelden";
knopf.disabled = false;
});