login.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. declare(strict_types=1);
  3. use App\App\Bootstrap;
  4. use App\Security\EntraAuth;
  5. require dirname(__DIR__) . '/src/autoload.php';
  6. Bootstrap::init();
  7. $app = Bootstrap::config('app');
  8. $auth = new EntraAuth();
  9. if (isset($_GET['logout']) && $_GET['logout'] === '1') {
  10. $auth->logout();
  11. header('Location: ' . Bootstrap::url('portal/login.php'));
  12. exit;
  13. }
  14. if ($auth->isLoggedIn()) {
  15. header('Location: ' . Bootstrap::url('portal/index.php'));
  16. exit;
  17. }
  18. $errorMessages = [
  19. 'access_denied' => 'Anmeldung nicht möglich: Ihr Konto ist für dieses Portal nicht freigeschaltet.',
  20. 'auth_failed' => 'Anmeldung fehlgeschlagen. Bitte erneut versuchen.',
  21. ];
  22. $error = $errorMessages[(string) ($_GET['error'] ?? '')] ?? '';
  23. $configured = $auth->isConfigured();
  24. $loginUrl = $configured ? $auth->getAuthorizationUrl() : '';
  25. ?><!doctype html>
  26. <html lang="de">
  27. <head>
  28. <meta charset="utf-8">
  29. <meta name="viewport" content="width=device-width, initial-scale=1">
  30. <title>Jugendwart-Portal Login</title>
  31. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/tokens.css')) ?>">
  32. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/base.css')) ?>">
  33. </head>
  34. <body class="admin-page">
  35. <header class="site-header">
  36. <div class="container header-inner">
  37. <a class="brand" href="<?= htmlspecialchars(Bootstrap::url('portal/login.php')) ?>">
  38. <img class="brand-logo" src="<?= htmlspecialchars(Bootstrap::url('assets/images/feuerwehr-logo-invers.webp')) ?>" alt="Feuerwehr Logo">
  39. <div class="brand-title"><?= htmlspecialchars((string) ($app['project_name'] ?? 'Jugendwart-Portal')) ?></div>
  40. </a>
  41. </div>
  42. </header>
  43. <main class="container">
  44. <section class="card auth-container">
  45. <h1>Jugendwart-Portal</h1>
  46. <p>Anmeldung für Jugendbetreuer zur Bestätigung eingegangener unterschriebener Formulare.</p>
  47. <?php if ($error !== ''): ?>
  48. <p class="alert alert-error"><?= htmlspecialchars($error) ?></p>
  49. <?php endif; ?>
  50. <?php if ($configured): ?>
  51. <a class="btn" href="<?= htmlspecialchars($loginUrl) ?>">Mit Microsoft anmelden</a>
  52. <?php else: ?>
  53. <p class="alert alert-warning">Die Microsoft-Entra-Anmeldung ist noch nicht konfiguriert.</p>
  54. <?php endif; ?>
  55. </section>
  56. </main>
  57. </body>
  58. </html>