Auth Phase 2: Session-Zugriffe kanalisieren (verhaltensneutral)

Vorbereitung für den JWT+Redis-Umschalter: alle verstreuten
$_SESSION['teacher_id'|admin_id']-Zugriffe laufen jetzt durch Session::-Helper,
damit der Backend-Tausch später EINE Datei (Session.php) ist statt 18 Stellen.

- Session.php: neue Admin-Helper adminId()/loginAdmin()/logoutAdmin()/
  requireAdmin() (mirror der Teacher-Helper). teacherId()/adminId() starten
  die Session jetzt lazy (Aufrufer müssen Session::start() nicht mehr).
- 18 Fundstellen kanalisiert (admin.php, admin-accounts, admin-modules,
  licenses, levels, waypoints, foto-upload, admin_gate, save_map).
- Country.php + app.php cockpit_href: über Session:: mit class_exists-Fallback
  (Bootstrap/Lib-Kontext, Session evtl. nicht geladen).

Verhaltensneutral: 14/14 Lint OK, Helper-Round-Trip 6/6 PASS, Live-Smoke
(admin status/modules/accounts/licenses) weist unauth. Requests wie bisher
mit 401/403 ab. AUTH_BACKEND bleibt 'session' — Live unverändert.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 16:33:14 +02:00
parent 5d94572569
commit 37f6238d05
12 changed files with 55 additions and 27 deletions
+4 -1
View File
@@ -103,7 +103,10 @@ if (!defined('JWT_REFRESH_TTL')) define('JWT_REFRESH_TTL', 2592000); // Refresh/
*/
function cockpit_href(): string {
if (session_status() === PHP_SESSION_NONE) @session_start();
if (!empty($_SESSION['teacher_id'])) return BASE_PATH . '/teacher';
// über Session:: kanalisiert; Fallback auf $_SESSION, falls die Lib im
// Bootstrap-Kontext (nur app.php) noch nicht geladen ist.
$tid = class_exists('Session') ? Session::teacherId() : ($_SESSION['teacher_id'] ?? null);
if ($tid) return BASE_PATH . '/teacher';
if (!empty($_COOKIE['ggs_session'])) return BASE_PATH . '/schueler';
return BASE_PATH . '/';
}