Haerte Verwaltungsflows und Zahlungsabgleich

This commit is contained in:
2026-08-07 12:02:41 +02:00
parent 39f662d541
commit 0f263c3a19
9 changed files with 461 additions and 101 deletions
+25 -4
View File
@@ -2,6 +2,11 @@
declare(strict_types=1);
if (PHP_SAPI !== 'cli') {
http_response_code(403);
exit("Dieses Skript ist nur fuer die Kommandozeile gedacht.\n");
}
/**
* Prueft die vier Kontofunktionen, die vor dem Go-Live ergaenzt wurden:
*
@@ -78,6 +83,22 @@ function konto_request(string $url, array &$cookies, string $method = 'GET', ?st
return ['status' => $status, 'body' => (string)$body, 'location' => $location];
}
function konto_follow_redirect(array $response, array &$cookies, string $baseUrl): array
{
if ($response['status'] < 300 || $response['status'] >= 400 || $response['location'] === null) {
return $response;
}
$location = (string)$response['location'];
if (preg_match('~^https?://~i', $location) === 1) {
$url = $location;
} else {
$url = $baseUrl . '/' . ltrim($location, '/');
}
return konto_request($url, $cookies);
}
/** @param array<string,string> $cookies */
function konto_csrf(string $url, array &$cookies): string
{
@@ -160,12 +181,12 @@ try {
// 3. Verifikation wird fuer Einladungen erzwungen
// ---------------------------------------------------------------
$csrf = konto_csrf("{$baseUrl}/mitarbeiterverwalten.php", $cookies);
$einladung = konto_request("{$baseUrl}/mitarbeiterverwalten.php", $cookies, 'POST', http_build_query([
$einladung = konto_follow_redirect(konto_request("{$baseUrl}/mitarbeiterverwalten.php", $cookies, 'POST', http_build_query([
'csrf_token' => $csrf,
'aktion' => 'zugang_gewaehren',
'mitgliedID' => (string)$participantId,
'rolle' => 'member',
]));
])), $cookies, $baseUrl);
pruefe(
'Einladung ohne bestaetigte Adresse wird abgelehnt',
str_contains($einladung['body'], 'bestätigt sein')
@@ -179,12 +200,12 @@ try {
$pdo->prepare('UPDATE users SET email_verified_at = NOW() WHERE id = ?')->execute([$userId]);
$csrf = konto_csrf("{$baseUrl}/mitarbeiterverwalten.php", $cookies);
$einladung = konto_request("{$baseUrl}/mitarbeiterverwalten.php", $cookies, 'POST', http_build_query([
$einladung = konto_follow_redirect(konto_request("{$baseUrl}/mitarbeiterverwalten.php", $cookies, 'POST', http_build_query([
'csrf_token' => $csrf,
'aktion' => 'zugang_gewaehren',
'mitgliedID' => (string)$participantId,
'rolle' => 'member',
]));
])), $cookies, $baseUrl);
pruefe(
'Einladung mit bestaetigter Adresse funktioniert',
str_contains($einladung['body'], 'Zugang wurde gewährt')