Frontend+API: Namen ändern (POST /user/rename)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-03 11:47:44 +02:00
parent 7ffc35808a
commit 844bbb44e7
5 changed files with 98 additions and 0 deletions
+11
View File
@@ -3,6 +3,17 @@
// Nutzername aus dem Pfad /u/<name>.
const username = decodeURIComponent(location.pathname.split("/")[2] || "");
document.getElementById("rename-form").addEventListener("submit", async (e) => {
e.preventDefault();
const res = await api.post("/user/rename", new FormData(e.target));
if (res.ok) {
location.href = `/u/${encodeURIComponent(res.data.username)}`;
} else {
document.getElementById("rename-msg").textContent =
res.data.error || "Umbenennen fehlgeschlagen.";
}
});
document.getElementById("delete-form").addEventListener("submit", async (e) => {
e.preventDefault();
if (!confirm("Konto wirklich unwiderruflich löschen?")) return;
+8
View File
@@ -19,6 +19,14 @@
<!-- Nur für den Eigentümer sichtbar -->
<section id="settings" hidden>
<h2>Einstellungen</h2>
<details>
<summary>Name ändern</summary>
<form id="rename-form">
<input name="user" type="text" placeholder="Neuer Nutzername" autocomplete="username">
<button type="submit">Namen ändern</button>
</form>
<p class="msg" id="rename-msg"></p>
</details>
<details>
<summary>Konto löschen</summary>
<form id="delete-form">