This commit is contained in:
2025-11-22 03:27:49 +01:00
parent 99098fa678
commit e3d5d9f2fc
2 changed files with 49 additions and 13 deletions

View File

@@ -1,6 +1,44 @@
// public/assets/js/header.js // public/assets/js/header.js
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
// -------------------------
// Login-Button
// -------------------------
const loginBtn = document.getElementById('loginButton');
if (loginBtn) {
loginBtn.addEventListener('click', function (event) {
event.preventDefault();
const currentPath = window.location.pathname || '/';
const currentQuery = window.location.search || '';
const redirect = currentPath + currentQuery;
// Sprache aus dem Label oben ziehen, falls vorhanden
const langLabelEl = document.getElementById('langCurrentLabel');
let lang = 'de';
if (langLabelEl && langLabelEl.textContent) {
lang = langLabelEl.textContent.trim().toLowerCase();
}
// Wenn wir bereits auf /login sind → nur zum #auth scrollen
if (currentPath === '/login' || currentPath === '/login/') {
const authEl = document.getElementById('auth');
if (authEl) {
authEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
return;
}
// Sonst: auf Login-Seite mit lang + redirect-Parameter
const url = '/login/?lang=' + encodeURIComponent(lang) +
'&redirect=' + encodeURIComponent(redirect) +
'#auth';
window.location.href = url;
});
}
// ------------------------- // -------------------------
// Avatar-Menü ein-/ausblenden // Avatar-Menü ein-/ausblenden
// ------------------------- // -------------------------
@@ -45,7 +83,6 @@ document.addEventListener('DOMContentLoaded', function () {
if (!backdrop) return; if (!backdrop) return;
backdrop.classList.remove('hidden'); backdrop.classList.remove('hidden');
// kleine Fokushilfe: Escape schließt, Klick auf Hintergrund auch
document.body.classList.add('overflow-hidden'); document.body.classList.add('overflow-hidden');
} }
@@ -56,7 +93,6 @@ document.addEventListener('DOMContentLoaded', function () {
logoutTarget = null; logoutTarget = null;
} }
// Logout-Link(s) abfangen
if (logoutButtons.length && backdrop && btnConfirm && btnCancel) { if (logoutButtons.length && backdrop && btnConfirm && btnCancel) {
logoutButtons.forEach(function (btn) { logoutButtons.forEach(function (btn) {
btn.addEventListener('click', function (event) { btn.addEventListener('click', function (event) {
@@ -90,7 +126,7 @@ document.addEventListener('DOMContentLoaded', function () {
hideLogoutModal(); hideLogoutModal();
}); });
// Klick auf Hintergrund (außerhalb der Card) schließt ebenfalls // Klick auf Hintergrund schließt Modal
backdrop.addEventListener('click', function (event) { backdrop.addEventListener('click', function (event) {
const card = backdrop.querySelector('div.w-full.max-w-sm'); const card = backdrop.querySelector('div.w-full.max-w-sm');
if (card && !card.contains(event.target)) { if (card && !card.contains(event.target)) {

View File

@@ -1,22 +1,22 @@
<?php <?php
// src/auth/logout.php // src/auth/logout.php
// wird durch public/auth/logout.php aufgerufen // wird von public/auth/logout.php eingebunden
require_once __DIR__ . '/../../config/fileload.php'; if (session_status() !== PHP_SESSION_ACTIVE) {
@session_start();
}
// Session läuft bereits durch fileload.php // Session leeren, aber NICHT komplett zerstören,
// → wir müssen sie nur leeren, nicht löschen // damit flash_set noch funktionieren kann.
// Session leeren (aber nicht zerstören flash_set muss funktionieren)
$_SESSION = []; $_SESSION = [];
session_regenerate_id(true); session_regenerate_id(true);
// Sprache mitnehmen // Sprache aus GET, falls vorhanden
$lang = $_GET['lang'] ?? 'de'; $lang = $_GET['lang'] ?? 'de';
// Flash-Meldung anzeigen // Flash-Meldung für die Login-Seite
flash_set('success', 'Du wurdest erfolgreich ausgeloggt.', 'login'); flash_set('success', 'Du wurdest erfolgreich ausgeloggt.', 'login');
// Redirect zur Startseite // Direkt zur Login-Seite weiterleiten
header('Location: /?lang=' . urlencode($lang)); header('Location: /login/?lang=' . urlencode($lang) . '#auth');
exit; exit;