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
+14 -3
View File
@@ -69,7 +69,13 @@ final class UserRepository
$this->write(['users' => $users]);
return $this->find($normalized) ?? [];
$createdUser = $this->find($normalized);
if ($createdUser === null) {
throw new RuntimeException('Der Account konnte nicht gespeichert werden.');
}
return $createdUser;
}
public function changePassword(string $username, string $password): void
@@ -94,9 +100,14 @@ final class UserRepository
mkdir(dirname($this->path), 0775, true);
}
file_put_contents(
$bytes = file_put_contents(
$this->path,
json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
LOCK_EX
);
if ($bytes === false) {
throw new RuntimeException('Die Benutzerdatei konnte nicht geschrieben werden. Bitte prüfe die Schreibrechte von storage/system.');
}
}
}