Files
omsorg/omsorgWeb/mitarbeiter-app/index.php
T
Felix KemmlerandClaude Sonnet 5 ee74ed65f5 Rebuild OMSORG Connect from scratch: login-only milestone
New omsorgWeb/mitarbeiter-app/ replaces the legacy PHP app for now
with just the login flow, built fresh instead of incrementally
refactored. Reuses the already-working omsorgCore JWT auth pattern
(login, silent refresh, session-stored token pair, /api/auth/me for
role+permissions) but drops everything legacy carried alongside it:
no local MySQL user cache, no admin/user-management endpoints, no
admin UI. Employee/user management stays exclusive to OMSORG Desktop
per architecture decision - Connect only ever acts on the current
user's own session.

logout.php additionally revokes the refresh token server-side via
omsorgcore_logout(), which the legacy version never did.

Verified end-to-end against a running omsorgCore instance: login,
dashboard via /api/auth/me, logout + token revocation, unauth
redirect, and wrong-credential error handling.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-07 14:32:55 +02:00

81 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require_once __DIR__ . '/lib/auth.php';
if (is_logged_in()) {
header('Location: pages/dashboard.php');
exit;
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
verify_csrf();
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if ($username !== '' && $password !== '') {
$result = omsorgcore_login(_omsorgcore_config(), $username, $password);
if ($result['ok']) {
session_regenerate_id(true);
_apply_token_pair($result['data']);
_refresh_profile();
header('Location: pages/dashboard.php');
exit;
}
if ($result['status'] === 429) {
$error = 'Zu viele Fehlversuche. Bitte warte ca. 10 Minuten.';
} elseif ($result['status'] === 0) {
$error = 'Server nicht erreichbar. Bitte später erneut versuchen.';
} else {
$error = 'Benutzername oder Passwort falsch.';
}
} else {
$error = 'Benutzername oder Passwort falsch.';
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>OMSORG Mitarbeiter-App Login</title>
<link rel="stylesheet" href="app.css">
</head>
<body>
<div class="login-page">
<div class="login-card glass">
<div class="brand" style="text-align:center">
<img src="assets/omsorg-wordmark-new.png" alt="OMSORG" style="width:210px;margin:0 auto 22px">
</div>
<h2 style="font-family:'KindelSerif',Georgia,serif;font-size:1.7rem;margin:0 0 6px">Mitarbeiter-App</h2>
<p class="hint" style="margin:0 0 22px">Melde dich mit deinem Benutzerkonto an.</p>
<?php if ($error): ?>
<div class="error" style="margin-bottom:16px"><?= e($error) ?></div>
<?php endif; ?>
<form method="post">
<?= csrf_field() ?>
<label>
Benutzername
<input type="text" name="username" autocomplete="username" required autofocus
value="<?= e($_POST['username'] ?? '') ?>">
</label>
<label>
Passwort
<input type="password" name="password" autocomplete="current-password" required>
</label>
<button type="submit" class="btn" style="width:100%;margin-top:6px">Anmelden</button>
</form>
</div>
</div>
</body>
</html>