initial import
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?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(__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);
|
||||
}
|
||||
Reference in New Issue
Block a user