Files
www-data 2f2e8869d6 Reorganize PHP internals and static assets
Move shared PHP code into private/, move JavaScript files into js/, and block direct access to private/. Remove unused API key and cache artifacts from the working tree.
2026-05-26 11:32:36 +02:00

53 lines
1.3 KiB
PHP

<?php
/*
* make-user.php
*
* CLI tool om handmatig gebruikers aan te maken.
*
* Gebruik:
*
* php make-user.php <email> "<full name>" <password> <admin:0|1>
*
* Voorbeeld:
*
* php make-user.php hans@example.nl "Hans Dijkema" "lang-genoeg-wachtwoord" 1
*/
require_once __DIR__ . '/auth.php';
if (PHP_SAPI !== 'cli') {
echo "CLI only\n";
exit(1);
}
if ($argc < 5) {
echo "Usage:\n";
echo " php make-user.php <email> \"<full name>\" <password> <admin:0|1>\n\n";
echo "Example:\n";
echo " php make-user.php hans@example.nl \"Hans Dijkema\" \"lang-genoeg-wachtwoord\" 1\n";
exit(1);
}
$email = $argv[1];
$fullName = $argv[2];
$password = $argv[3];
$isAdmin = $argv[4] === '1';
try {
$auth = new RacketSandboxAuth(dirname(__DIR__) . '/data/racket-sandbox.sqlite');
$user = $auth->createUser($email, $fullName, $password, $isAdmin, true);
echo "Created user\n";
echo "------------\n";
echo "ID: " . $user->id() . "\n";
echo "Email: " . $user->email() . "\n";
echo "Full name: " . $user->fullName() . "\n";
echo "Admin: " . ($user->isAdmin() ? "yes" : "no") . "\n";
echo "Enabled: " . ($user->isEnabled() ? "yes" : "no") . "\n";
exit(0);
} catch (Throwable $e) {
echo "Error: " . $e->getMessage() . "\n";
exit(1);
}