Fix setup/auth flow and harden storage write failures

This commit is contained in:
2026-04-11 19:24:44 +02:00
parent 4b95cc3dcb
commit eba5f915c1
3 changed files with 40 additions and 9 deletions
+15 -4
View File
@@ -30,6 +30,12 @@ final class App
$hasUsers = $this->users->hasAnyUsers();
$isAuthenticated = $this->auth->check();
// A failed setup must never leave the app in a half-authenticated redirect loop.
if (!$hasUsers && $isAuthenticated) {
$this->auth->logout();
$isAuthenticated = false;
}
if (!$hasUsers) {
if ($path === '/login') {
$path = '/setup';
@@ -130,10 +136,15 @@ final class App
redirect('/setup');
}
$user = $this->users->create($username, $password, true);
$this->auth->login($user);
flash('success', 'Der erste Account wurde erstellt. Du kannst direkt loslegen.');
redirect('/');
try {
$user = $this->users->create($username, $password, true);
$this->auth->login($user);
flash('success', 'Der erste Account wurde erstellt. Du kannst direkt loslegen.');
redirect('/');
} catch (RuntimeException $exception) {
flash('error', $exception->getMessage());
redirect('/setup');
}
}
private function showLogin(): void