diff --git a/backend/main.py b/backend/main.py index 4a9ee01..f1934db 100644 --- a/backend/main.py +++ b/backend/main.py @@ -327,7 +327,7 @@ MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media") os.makedirs(MEDIA_DIR, exist_ok=True) app.mount("/media", StaticFiles(directory=MEDIA_DIR), name="media") -APP_VER = "785" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "786" # muss mit APP_VER in app.js übereinstimmen @app.get("/.well-known/assetlinks.json") async def assetlinks(): diff --git a/backend/routes/profile.py b/backend/routes/profile.py index 9cb0667..783951f 100644 --- a/backend/routes/profile.py +++ b/backend/routes/profile.py @@ -142,3 +142,28 @@ async def put_world_config(body: WorldConfigIn, user=Depends(get_current_user)): conn.execute("UPDATE users SET world_config=? WHERE id=?", (_json.dumps(body.config), user['id'])) return {"status": "ok"} + + +# ---------------------------------------------------------- +# DELETE /profile/account — Konto unwiderruflich löschen +# ---------------------------------------------------------- +@router.delete('/account') +async def delete_account(user=Depends(get_current_user)): + """Löscht das Konto und alle zugehörigen Daten unwiderruflich.""" + uid = user['id'] + with db() as conn: + # Alle Hunde-IDs des Users + dog_ids = [r['id'] for r in conn.execute( + "SELECT id FROM dogs WHERE user_id=?", (uid,)).fetchall()] + for did in dog_ids: + conn.execute("DELETE FROM diary WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM health WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM training_sessions WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM training_streaks WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM expenses WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM dogs WHERE user_id=?", (uid,)) + conn.execute("DELETE FROM push_subscriptions WHERE user_id=?", (uid,)) + conn.execute("DELETE FROM notifications WHERE user_id=?", (uid,)) + conn.execute("DELETE FROM forum_posts WHERE user_id=?", (uid,)) + conn.execute("DELETE FROM users WHERE id=?", (uid,)) + return {"status": "deleted"} diff --git a/backend/static/index.html b/backend/static/index.html index 8b0f233..ba840bd 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -575,10 +575,10 @@
- - - - + + + + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index d7377de..c6d7f40 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '785'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '786'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.5.0'; // ← semantische Version, wird bei make release gesetzt const IS_STAGING = location.hostname === 'staging.banyaro.app'; // Cache-Bust-Parameter nach Update-Reload sofort entfernen diff --git a/backend/static/js/pages/settings.js b/backend/static/js/pages/settings.js index b772d0f..0999352 100644 --- a/backend/static/js/pages/settings.js +++ b/backend/static/js/pages/settings.js @@ -287,6 +287,15 @@ window.Page_settings = (() => { Abmelden + @@ -789,6 +798,24 @@ window.Page_settings = (() => { _render(); }); + document.getElementById('settings-delete-account-btn')?.addEventListener('click', async () => { + const ok = await UI.modal.confirm({ + title: 'Konto unwiderruflich löschen?', + body: 'Alle deine Daten (Tagebuch, Gesundheit, Training, Fotos) werden dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.', + confirmText: 'Ja, Konto löschen', + danger: true, + }); + if (!ok) return; + try { + await API.del('/profile/account'); + _appState.user = null; _appState.dogs = []; _appState.activeDog = null; + UI.toast.info('Dein Konto wurde gelöscht.'); + App.navigate('welcome'); + } catch { + UI.toast.error('Konto konnte nicht gelöscht werden. Bitte versuche es erneut.'); + } + }); + document.getElementById('settings-install-btn')?.addEventListener('click', () => { App.navigate('welcome', true, { install: true }); }); diff --git a/backend/static/sw.js b/backend/static/sw.js index 0149aa7..3f2382c 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -3,7 +3,7 @@ Offline-Cache + Push Notifications + Tile-Cache ============================================================ */ -const CACHE_VERSION = 'by-v785'; +const CACHE_VERSION = 'by-v786'; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache