diff options
| -rw-r--r-- | README.md | 1 | ||||
| -rwxr-xr-x | bin/newuser | 36 |
2 files changed, 37 insertions, 0 deletions
@@ -24,6 +24,7 @@ the basic steps for setup are: 4. run the development server with `bin/devserver <port>`, or set it up with fpm in your web server 5. run at least one worker with `bin/worker` +6. create an account for yourself using `bin/newuser` you can poke around with `bin/shell` which will launch the interactive php shell and initialise all the composer autoloads and so on diff --git a/bin/newuser b/bin/newuser new file mode 100755 index 0000000..165a598 --- /dev/null +++ b/bin/newuser @@ -0,0 +1,36 @@ +#!/usr/bin/env php +<?php + +require __DIR__ . '/../vendor/autoload.php'; +foreach (glob(__DIR__ . '/../misc/*.php') as $filename) { + require $filename; +} + +use Digitigrade\Model\Actor; +use Digitigrade\Model\UserAccount; + +if ($argc != 4) { + error_log('usage: bin/newuser <handle> <email> <password>'); + exit(1); +} + +$handle = $argv[1]; +$email = $argv[2]; +$password = $argv[3]; +$admin = UserAccount::count() <= 0; // make admin if there aren't any other users + +if (Actor::findLocalByHandle($handle) != null) { + error_log("there is already a local user with handle @$handle!"); + exit(1); +} +if (UserAccount::findByEmail($email) != null) { + error_log("there is already a local user with email address $email!"); + exit(1); +} + +$user = UserAccount::create($email, $password); +$user->createLinkedActor($handle); +$user->isAdmin = $admin; +$user->save(); + +echo "created user @$handle" . ($admin ? ' with admin permissions' : '') . "\n";
\ No newline at end of file |
