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>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
b6c1389c55
commit
ee74ed65f5
@@ -6,6 +6,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
This is the OMSORG website plus **OMSORG Connect**, an internal employee web app ("Mitarbeiter-App") for a German nursing care company. There is no build system — everything is plain PHP, HTML, CSS, and vanilla JS deployed directly to a web server (`htdocs`).
|
||||
|
||||
**OMSORG Connect wird gerade komplett neu aufgebaut.** `mitarbeiter-app-legacy/` ist die alte, produktiv gelaufene Version — dient nur noch als Referenz/Vorlage, wird nicht mehr weiterentwickelt. Der Rest dieser Datei beschreibt `mitarbeiter-app-legacy/`, nicht den Neuaufbau. Die aktive Entwicklung findet in `mitarbeiter-app/` statt (aktuell: nur Login-Flow gegen `omsorgCore`, siehe unten "Neuaufbau"). Auth in der Legacy-Version läuft **nicht mehr** über lokales bcrypt/Session-Lockout wie unten in "Entry point" beschrieben — das ist bereits auf omsorgCore-JWT-Auth umgestellt (`lib/omsorgCoreClient.php`, `lib/auth.php`), lokales MySQL dient dort nur noch als Read-Cache für Profildaten.
|
||||
|
||||
### Neuaufbau (`mitarbeiter-app/`)
|
||||
Frischer, minimaler PHP-Login-Flow gegen `omsorgCore` — kein Framework, gleiches Deployment-Modell wie die Legacy-App. Bewusst (noch) ohne: Antragsformulare, Dienstplan, Downloads, Admin-Oberfläche, PWA-Assets, MySQL. Admin-/Mitarbeiterverwaltung gehört nicht hierher, sondern exklusiv zu OMSORG Desktop (`omsorgapp`) — Connect zeigt/bearbeitet ausschließlich Daten des eingeloggten Nutzers selbst.
|
||||
|
||||
This project is one part of the OMSORG monorepo — see the root `CLAUDE.md` (`../CLAUDE.md`) for the overall platform picture and `../REQUIREMENTS.md` for functional/non-functional requirements with FR-IDs. This app is the reference implementation for **OMSORG Connect**; its MySQL database is expected to eventually move behind the shared `omsorgCore` backend (currently empty, planned as C#/.NET + PostgreSQL) rather than staying a standalone data store.
|
||||
|
||||
## Deployment
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../lib/auth.php';
|
||||
|
||||
// Best-effort: Refresh-Token serverseitig widerrufen, damit er nicht bis zum natürlichen
|
||||
// Ablauf gültig bleibt. Fehler hier dürfen den lokalen Logout nicht blockieren.
|
||||
if (!empty($_SESSION['omsorgcore_refresh_token'])) {
|
||||
omsorgcore_logout(_omsorgcore_config(), $_SESSION['omsorgcore_refresh_token']);
|
||||
}
|
||||
|
||||
$_SESSION = [];
|
||||
if (ini_get('session.use_cookies')) {
|
||||
$p = session_get_cookie_params();
|
||||
setcookie(session_name(), '', time() - 42000,
|
||||
$p['path'], $p['domain'], $p['secure'], $p['httponly']);
|
||||
}
|
||||
session_destroy();
|
||||
header('Location: ../index.php');
|
||||
exit;
|
||||
@@ -0,0 +1,118 @@
|
||||
/* Minimaler Start-Stil für das Login-Milestone. Wird erweitert, sobald weitere Seiten
|
||||
dazukommen - siehe mitarbeiter-app-legacy/app.css für das volle Design als Referenz. */
|
||||
|
||||
:root{
|
||||
--cyan:#10d7e6;--cyan2:#36f2ff;--dark:#031522;
|
||||
--glass:rgba(0,35,51,.74);--line:rgba(170,240,250,.42);
|
||||
--text:#f7ffff;--muted:#d7f6f8;
|
||||
--sidebar-w:240px;
|
||||
}
|
||||
|
||||
*{box-sizing:border-box}
|
||||
html{background:#031522}
|
||||
body{
|
||||
margin:0;min-height:100vh;color:var(--text);
|
||||
font-family:Arial,Helvetica,sans-serif;line-height:1.45;
|
||||
background:#031522;
|
||||
}
|
||||
a{color:inherit;text-decoration:none}
|
||||
img{display:block;max-width:100%}
|
||||
|
||||
.glass{
|
||||
border:1px solid var(--line);border-radius:22px;
|
||||
background:linear-gradient(145deg,rgba(0,35,51,.78),rgba(8,105,122,.28));
|
||||
box-shadow:0 22px 70px rgba(0,0,0,.28);
|
||||
backdrop-filter:blur(16px);
|
||||
}
|
||||
|
||||
.btn{
|
||||
display:inline-flex;align-items:center;justify-content:center;
|
||||
gap:10px;border:1px solid rgba(255,255,255,.24);border-radius:13px;
|
||||
background:linear-gradient(135deg,#25e2e9,#079aaa);
|
||||
color:#fff;font-weight:900;padding:14px 18px;cursor:pointer;
|
||||
box-shadow:0 14px 38px rgba(0,215,230,.18);font:inherit;
|
||||
}
|
||||
|
||||
form{display:grid;gap:14px}
|
||||
label{display:grid;gap:7px;font-weight:800;color:#fff}
|
||||
input{
|
||||
width:100%;border:1px solid rgba(170,240,250,.36);border-radius:12px;
|
||||
padding:14px;background:rgba(2,11,22,.54);color:#fff;font:inherit;
|
||||
}
|
||||
|
||||
.error{
|
||||
padding:12px 14px;border:1px solid rgba(255,130,130,.45);
|
||||
border-radius:12px;background:rgba(255,0,0,.13);color:#fff;
|
||||
}
|
||||
.hint{color:var(--muted);font-size:.9rem}
|
||||
|
||||
.login-page{display:grid;place-items:center;min-height:100vh;padding:26px}
|
||||
.login-card{width:min(100%,450px);padding:30px}
|
||||
|
||||
.dashboard-layout{
|
||||
display:grid;
|
||||
grid-template-columns:1fr;
|
||||
padding-left:var(--sidebar-w);
|
||||
min-height:100vh;
|
||||
}
|
||||
|
||||
.sidebar{
|
||||
position:fixed;top:0;left:0;width:var(--sidebar-w);height:100vh;overflow-y:auto;
|
||||
display:flex;flex-direction:column;gap:0;
|
||||
border-radius:0;border-top:none;border-bottom:none;border-left:none;
|
||||
padding:0;
|
||||
}
|
||||
.sidebar-brand{padding:22px 20px 16px;border-bottom:1px solid rgba(170,240,250,.18)}
|
||||
.sidebar-brand img{width:160px;height:auto}
|
||||
.sidebar-app-name{
|
||||
display:block;margin-top:6px;
|
||||
color:var(--cyan2);text-transform:uppercase;
|
||||
letter-spacing:.16em;font-size:.74rem;font-weight:900;
|
||||
}
|
||||
.sidebar-user{
|
||||
display:grid;grid-template-columns:40px 1fr;gap:12px;
|
||||
align-items:center;padding:16px 20px;
|
||||
border-bottom:1px solid rgba(170,240,250,.12);
|
||||
}
|
||||
.sidebar-avatar{
|
||||
width:40px;height:40px;display:grid;place-items:center;
|
||||
border-radius:50%;background:linear-gradient(135deg,#20e1ea,#078fa3);
|
||||
font-weight:900;font-size:1.1rem;color:#fff;
|
||||
}
|
||||
.sidebar-user b{display:block;font-size:.92rem}
|
||||
.sidebar-user small{display:block;color:var(--muted);font-size:.78rem;margin-top:2px}
|
||||
|
||||
.sidebar-nav{padding:16px 12px 0;flex:1}
|
||||
.sidebar-nav a{
|
||||
display:flex;align-items:center;gap:10px;
|
||||
border-radius:13px;padding:11px 12px;
|
||||
color:#ebfdff;font-weight:800;font-size:.92rem;
|
||||
border:1px solid transparent;margin-bottom:4px;
|
||||
}
|
||||
.sidebar-nav a.active{
|
||||
background:linear-gradient(135deg,rgba(32,225,234,.22),rgba(7,143,163,.18));
|
||||
border-color:rgba(54,242,255,.45);
|
||||
color:#fff;
|
||||
}
|
||||
.nav-icon{font-size:1rem;opacity:.85}
|
||||
|
||||
.sidebar-footer{padding:16px 20px;border-top:1px solid rgba(170,240,250,.12);margin-top:auto}
|
||||
.sidebar-logout{
|
||||
display:block;text-align:center;
|
||||
border:1px solid rgba(170,240,250,.28);
|
||||
border-radius:13px;padding:11px;
|
||||
background:rgba(255,255,255,.06);
|
||||
font-weight:900;font-size:.88rem;
|
||||
}
|
||||
|
||||
.main-content{overflow-y:auto;padding:48px 40px;min-height:100vh}
|
||||
.main-inner{max-width:860px}
|
||||
.main-title{font-size:2.4rem;line-height:1;margin:0 0 12px;color:#fff}
|
||||
.main-title span{color:var(--cyan)}
|
||||
.main-sub{color:var(--muted);font-size:1.05rem;margin:0}
|
||||
|
||||
@media(max-width:860px){
|
||||
.dashboard-layout{grid-template-columns:1fr;padding-left:0}
|
||||
.sidebar{position:static;width:100%;height:auto}
|
||||
.main-content{padding:20px 16px}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
@@ -0,0 +1,80 @@
|
||||
<?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>
|
||||
@@ -0,0 +1 @@
|
||||
Require all denied
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
// Auth läuft vollständig über omsorgCore (siehe omsorgCoreClient.php) - kein lokaler
|
||||
// Credential-Check, keine lokale users-Tabelle. Alles, was eine Seite über den eingeloggten
|
||||
// Nutzer wissen muss, kommt aus $_SESSION['omsorgcore_profile'] (befüllt von /api/auth/me:
|
||||
// username, firstName, lastName, email, phoneNumber, role, permissions).
|
||||
require_once __DIR__ . '/omsorgCoreClient.php';
|
||||
|
||||
$secure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|
||||
|| (($_SERVER['SERVER_PORT'] ?? null) == 443);
|
||||
session_set_cookie_params([
|
||||
'lifetime' => 0,
|
||||
'path' => '/',
|
||||
'httponly' => true,
|
||||
'secure' => $secure,
|
||||
'samesite' => 'Lax',
|
||||
]);
|
||||
session_name('OMSORG_FELIX_APP');
|
||||
session_start();
|
||||
|
||||
function _omsorgcore_config(): array {
|
||||
static $config = null;
|
||||
if ($config === null) {
|
||||
$config = require __DIR__ . '/config.php';
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
// Stellt sicher, dass $_SESSION['omsorgcore_access_token'] gültig ist - erneuert bei Bedarf still
|
||||
// über den Refresh-Token (Server-seitig, der Browser bekommt nie einen Token zu sehen).
|
||||
function _ensure_fresh_token(): bool {
|
||||
if (empty($_SESSION['omsorgcore_access_token']) || empty($_SESSION['omsorgcore_refresh_token'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$expiresAt = $_SESSION['omsorgcore_access_expires_at'] ?? null;
|
||||
$stillValid = $expiresAt && strtotime($expiresAt) > time() + 30; // 30s Puffer
|
||||
if ($stillValid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$result = omsorgcore_refresh(_omsorgcore_config(), $_SESSION['omsorgcore_refresh_token']);
|
||||
if (!$result['ok']) {
|
||||
_clear_omsorgcore_session();
|
||||
return false;
|
||||
}
|
||||
|
||||
_apply_token_pair($result['data']);
|
||||
return true;
|
||||
}
|
||||
|
||||
function _apply_token_pair(array $data): void {
|
||||
$_SESSION['omsorgcore_access_token'] = $data['accessToken'];
|
||||
$_SESSION['omsorgcore_refresh_token'] = $data['refreshToken'];
|
||||
$_SESSION['omsorgcore_access_expires_at'] = $data['expiresAt'];
|
||||
// Noch nicht verdrahtet (kein change-password.php in diesem Milestone) - Flag wird aber
|
||||
// schon gesetzt, damit das Nachziehen später keine Änderung an Login/Session-Core braucht.
|
||||
$_SESSION['omsorgcore_must_change_password'] = !empty($data['mustChangePassword']);
|
||||
}
|
||||
|
||||
function _clear_omsorgcore_session(): void {
|
||||
unset(
|
||||
$_SESSION['omsorgcore_access_token'],
|
||||
$_SESSION['omsorgcore_refresh_token'],
|
||||
$_SESSION['omsorgcore_access_expires_at'],
|
||||
$_SESSION['omsorgcore_must_change_password'],
|
||||
$_SESSION['omsorgcore_profile']
|
||||
);
|
||||
}
|
||||
|
||||
// Lädt/cached /api/auth/me in der Session (Username/Rolle/Rechte). Wird nach Login und bei
|
||||
// jedem is_logged_in()-Aufruf ohne gültigen Cache erneuert.
|
||||
function _refresh_profile(): bool {
|
||||
$result = omsorgcore_me(_omsorgcore_config(), $_SESSION['omsorgcore_access_token']);
|
||||
if (!$result['ok']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$_SESSION['omsorgcore_profile'] = $result['data'];
|
||||
return true;
|
||||
}
|
||||
|
||||
function is_logged_in(): bool {
|
||||
if (!_ensure_fresh_token()) {
|
||||
return false;
|
||||
}
|
||||
if (empty($_SESSION['omsorgcore_profile'])) {
|
||||
return _refresh_profile();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function require_login(): void {
|
||||
if (!is_logged_in()) {
|
||||
header('Location: ../index.php');
|
||||
exit;
|
||||
}
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST)) {
|
||||
verify_csrf();
|
||||
}
|
||||
}
|
||||
|
||||
function csrf_token(): string {
|
||||
if (empty($_SESSION['csrf_token'])) {
|
||||
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||
}
|
||||
return $_SESSION['csrf_token'];
|
||||
}
|
||||
|
||||
function csrf_field(): string {
|
||||
return '<input type="hidden" name="csrf_token" value="' . csrf_token() . '">';
|
||||
}
|
||||
|
||||
function verify_csrf(): void {
|
||||
$token = $_POST['csrf_token'] ?? '';
|
||||
if (!hash_equals(csrf_token(), $token)) {
|
||||
http_response_code(403);
|
||||
exit('Ungültige Anfrage.');
|
||||
}
|
||||
}
|
||||
|
||||
function current_username(): string {
|
||||
return $_SESSION['omsorgcore_profile']['username'] ?? '';
|
||||
}
|
||||
|
||||
function current_name(): string {
|
||||
$profile = $_SESSION['omsorgcore_profile'] ?? [];
|
||||
$name = trim(($profile['firstName'] ?? '') . ' ' . ($profile['lastName'] ?? ''));
|
||||
return $name !== '' ? $name : current_username();
|
||||
}
|
||||
|
||||
function current_role(): string {
|
||||
return $_SESSION['omsorgcore_profile']['role'] ?? '';
|
||||
}
|
||||
|
||||
function e(string $s): string {
|
||||
return htmlspecialchars($s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
// Vorlage: nach config.secret.php kopieren und mit echten Werten füllen.
|
||||
// config.secret.php niemals ins Repo/Backup geben.
|
||||
return [
|
||||
// Produktiv auf die echte omsorgCore-URL überschreiben (Default in config.php ist localhost, nur für lokale Entwicklung):
|
||||
// 'omsorg_core_url' => 'https://core.omsorg-pflegedienste.de',
|
||||
];
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// Minimale Hülle für dieses Milestone - nur Dashboard im Nav, keine Admin-Sichtbarkeit
|
||||
// (Connect hat kategorisch keine Admin-Oberfläche, siehe CLAUDE.md).
|
||||
function layout_start(string $title): void {
|
||||
$name = current_name();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title><?= e($title) ?></title>
|
||||
<link rel="stylesheet" href="../app.css">
|
||||
<meta name="csrf-token" content="<?= csrf_token() ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="dashboard-layout">
|
||||
|
||||
<aside class="sidebar glass">
|
||||
<div class="sidebar-brand">
|
||||
<img src="../assets/omsorg-wordmark-new.png" alt="OMSORG">
|
||||
<span class="sidebar-app-name">Mitarbeiter-App</span>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-user">
|
||||
<div class="sidebar-avatar"><?= e(mb_substr($name, 0, 1)) ?></div>
|
||||
<div>
|
||||
<b><?= e($name) ?></b>
|
||||
<small><?= e(current_role()) ?></small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="sidebar-nav">
|
||||
<a href="dashboard.php" class="active">
|
||||
<span class="nav-icon">⊞</span><span class="nav-label"> Dashboard</span>
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<div class="sidebar-footer">
|
||||
<a href="../actions/logout.php" class="sidebar-logout">Abmelden</a>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="main-content">
|
||||
<div class="main-inner">
|
||||
<?php
|
||||
}
|
||||
|
||||
function layout_end(): void {
|
||||
?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
// Einzige Stelle, die HTTP-Details von omsorgCore kennt (Basis-URL, Header, JSON-(De)Kodierung) -
|
||||
// analog zu httpClient.cjs/authClient.cjs in omsorgapp. Alle Aufrufer bekommen ein einheitliches
|
||||
// Ergebnis-Array: ['ok' => bool, 'status' => int, 'data' => array|null].
|
||||
//
|
||||
// Nur Auth-Endpunkte - Connect verwaltet keine anderen Nutzer/Rollen/Mitarbeiter (das bleibt
|
||||
// OMSORG Desktop vorbehalten), deshalb fehlen hier bewusst omsorgcore_users_*/roles_*/employees_*.
|
||||
|
||||
function omsorgcore_request(array $config, string $method, string $path, ?array $body = null, ?string $accessToken = null): array
|
||||
{
|
||||
$url = rtrim($config['omsorg_core_url'], '/') . $path;
|
||||
|
||||
$headers = ['Content-Type: application/json'];
|
||||
if ($accessToken !== null) {
|
||||
$headers[] = 'Authorization: Bearer ' . $accessToken;
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
CURLOPT_HTTPHEADER => $headers,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 15,
|
||||
CURLOPT_POSTFIELDS => $body !== null ? json_encode($body) : null,
|
||||
]);
|
||||
|
||||
$responseBody = curl_exec($ch);
|
||||
if ($responseBody === false) {
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
return ['ok' => false, 'status' => 0, 'data' => null, 'error' => $error];
|
||||
}
|
||||
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
$data = null;
|
||||
if ($responseBody !== '') {
|
||||
$decoded = json_decode($responseBody, true);
|
||||
$data = json_last_error() === JSON_ERROR_NONE ? $decoded : null;
|
||||
}
|
||||
|
||||
return ['ok' => $status >= 200 && $status < 300, 'status' => $status, 'data' => $data];
|
||||
}
|
||||
|
||||
// --- Auth ---
|
||||
|
||||
function omsorgcore_login(array $config, string $username, string $password): array
|
||||
{
|
||||
return omsorgcore_request($config, 'POST', '/api/auth/login', ['username' => $username, 'password' => $password]);
|
||||
}
|
||||
|
||||
function omsorgcore_refresh(array $config, string $refreshToken): array
|
||||
{
|
||||
return omsorgcore_request($config, 'POST', '/api/auth/refresh', ['refreshToken' => $refreshToken]);
|
||||
}
|
||||
|
||||
function omsorgcore_logout(array $config, string $refreshToken): array
|
||||
{
|
||||
return omsorgcore_request($config, 'POST', '/api/auth/logout', ['refreshToken' => $refreshToken]);
|
||||
}
|
||||
|
||||
function omsorgcore_me(array $config, string $accessToken): array
|
||||
{
|
||||
return omsorgcore_request($config, 'GET', '/api/auth/me', null, $accessToken);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../lib/auth.php';
|
||||
require_once __DIR__ . '/../lib/layout.php';
|
||||
require_login();
|
||||
|
||||
layout_start('Dashboard – Mitarbeiter-App');
|
||||
?>
|
||||
<h1 class="main-title">Willkommen, <span><?= e(current_name()) ?></span></h1>
|
||||
<p class="main-sub">Eingeloggt als <?= e(current_username()) ?> (<?= e(current_role()) ?>).</p>
|
||||
<?php
|
||||
layout_end();
|
||||
Reference in New Issue
Block a user