commit
This commit is contained in:
@@ -1,6 +1,44 @@
|
||||
// public/assets/js/header.js
|
||||
|
||||
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
|
||||
// -------------------------
|
||||
@@ -45,7 +83,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
if (!backdrop) return;
|
||||
|
||||
backdrop.classList.remove('hidden');
|
||||
// kleine Fokushilfe: Escape schließt, Klick auf Hintergrund auch
|
||||
document.body.classList.add('overflow-hidden');
|
||||
}
|
||||
|
||||
@@ -56,7 +93,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
logoutTarget = null;
|
||||
}
|
||||
|
||||
// Logout-Link(s) abfangen
|
||||
if (logoutButtons.length && backdrop && btnConfirm && btnCancel) {
|
||||
logoutButtons.forEach(function (btn) {
|
||||
btn.addEventListener('click', function (event) {
|
||||
@@ -90,7 +126,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
hideLogoutModal();
|
||||
});
|
||||
|
||||
// Klick auf Hintergrund (außerhalb der Card) schließt ebenfalls
|
||||
// Klick auf Hintergrund schließt Modal
|
||||
backdrop.addEventListener('click', function (event) {
|
||||
const card = backdrop.querySelector('div.w-full.max-w-sm');
|
||||
if (card && !card.contains(event.target)) {
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
<?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
|
||||
// → wir müssen sie nur leeren, nicht löschen
|
||||
|
||||
// Session leeren (aber nicht zerstören – flash_set muss funktionieren)
|
||||
// Session leeren, aber NICHT komplett zerstören,
|
||||
// damit flash_set noch funktionieren kann.
|
||||
$_SESSION = [];
|
||||
session_regenerate_id(true);
|
||||
|
||||
// Sprache mitnehmen
|
||||
// Sprache aus GET, falls vorhanden
|
||||
$lang = $_GET['lang'] ?? 'de';
|
||||
|
||||
// Flash-Meldung anzeigen
|
||||
// Flash-Meldung für die Login-Seite
|
||||
flash_set('success', 'Du wurdest erfolgreich ausgeloggt.', 'login');
|
||||
|
||||
// Redirect zur Startseite
|
||||
header('Location: /?lang=' . urlencode($lang));
|
||||
// Direkt zur Login-Seite weiterleiten
|
||||
header('Location: /login/?lang=' . urlencode($lang) . '#auth');
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user