Add shared auth login flow

This commit is contained in:
2026-06-15 11:20:22 +02:00
parent b648d789e9
commit da29732cba
9 changed files with 883 additions and 1 deletions
+86
View File
@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/../service.php';
function render_auth_login_page(array $state): void
{
$identifierValue = auth_escape_html((string) ($state['identifier_value'] ?? ''));
$identifierError = (string) ($state['errors']['identifier'] ?? '');
$passwordError = (string) ($state['errors']['password'] ?? '');
$pageTitle = 'Anmeldung zum Naurua ERP';
$headerTitle = 'Willkommen im Naurua ERP';
$subtitle = 'Mit Benutzername oder E-Mail anmelden';
$csrf = auth_csrf_token();
$identifierInvalid = $identifierError !== '';
$passwordInvalid = $passwordError !== '';
echo '<!doctype html>';
echo '<html lang="de">';
echo '<head>';
echo '<meta charset="UTF-8">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
echo '<title>' . auth_escape_html($pageTitle) . '</title>';
echo '<link rel="stylesheet" href="/assets/styles.css">';
echo '</head>';
echo '<body class="sg-vsf-register-step-1-page">';
echo '<h1 class="sg-main-heading">Anmeldung Naurua ERP</h1>';
echo '<main class="sg-vsf-register-step-1">';
echo '<article class="sg-card sg-object-card sg-object-card--variable-height sg-vsf-register-step-1__card" data-pattern="object-card" aria-label="Anmeldung">';
echo '<header class="sg-card-segment sg-card-segment--header sg-card-segment--darkblue sg-object-card__header" data-pattern-part="object-card-header">';
echo '<div class="sg-strong">' . auth_escape_html($headerTitle) . '</div>';
echo '</header>';
echo '<footer class="sg-card-segment sg-card-segment--gray" aria-label="Anmeldeformular">';
echo '<div class="sg-form-sections-card-wrapper" data-pattern="form-sections" aria-label="Formular mit Abschnitten">';
echo '<form class="sg-form-sections-card" action="/" method="post" novalidate>';
echo '<input type="hidden" name="csrf_token" value="' . auth_escape_html($csrf) . '">';
echo '<div class="sg-form-sections-card__body" data-pattern-part="form-body">';
echo '<h2 class="sg-strong sg-form-sections-card__title">' . auth_escape_html($subtitle) . '</h2>';
echo '<div class="sg-form-sections-card__field-group">';
echo '<label class="sg-labeled-input-row">';
echo '<span class="sg-label">Benutzername oder E-Mail</span>';
echo '<span class="sg-input-validation-stack">';
echo '<input class="sg-interaction-element sg-input-single-line sg-input-single-line--inactive-selectable sg-form-inactive-selectable" type="text" name="identifier" value="' . $identifierValue . '" aria-label="Benutzername oder E-Mail" autocomplete="username" autocapitalize="none" spellcheck="false"';
if ($identifierInvalid) {
echo ' aria-invalid="true" aria-describedby="login-identifier-error"';
}
echo '>';
if ($identifierInvalid) {
echo '<span class="sg-form-validation-text" id="login-identifier-error">' . auth_escape_html($identifierError) . '</span>';
}
echo '</span>';
echo '</label>';
echo '<label class="sg-labeled-input-row">';
echo '<span class="sg-label">Passwort</span>';
echo '<span class="sg-input-validation-stack">';
echo '<input class="sg-interaction-element sg-input-single-line sg-input-single-line--inactive-selectable sg-form-inactive-selectable" type="password" name="password" aria-label="Passwort" autocomplete="current-password"';
if ($passwordInvalid) {
echo ' aria-invalid="true" aria-describedby="login-password-error"';
}
echo '>';
if ($passwordInvalid) {
echo '<span class="sg-form-validation-text" id="login-password-error">' . auth_escape_html($passwordError) . '</span>';
}
echo '</span>';
echo '</label>';
echo '</div>';
echo '</div>';
echo '<footer class="sg-form-sections-card__actions-segment" data-pattern-part="form-actions-segment">';
echo '<div class="sg-form-sections-card__actions" data-pattern-part="form-actions">';
echo '<button class="sg-interaction-element sg-button sg-button--active sg-form-sections-card__action" type="reset">Abbrechen</button>';
echo '<button class="sg-interaction-element sg-button sg-button--process sg-form-sections-card__action" type="submit">Anmelden</button>';
echo '</div>';
echo '</footer>';
echo '</form>';
echo '</div>';
echo '</footer>';
echo '</article>';
echo '</main>';
echo '</body>';
echo '</html>';
}