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>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// 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;
|
||||
});
|
||||
Reference in New Issue
Block a user