forked from etsy/411
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_user.php
More file actions
executable file
·34 lines (29 loc) · 888 Bytes
/
Copy pathcreate_user.php
File metadata and controls
executable file
·34 lines (29 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env php
<?php
/**
* Script to create a user.
*/
require_once(__DIR__ . '/../phplib/411bootstrap.php');
// Set the site.
$site = null;
$sites = FOO\SiteFinder::getAll();
if(count($sites) == 1) {
$site = $sites[0];
} else {
$site = FOO\SiteFinder::getById((int)FOO\Util::prompt("Site ID"));
}
if(is_null($site)) {
echo "Site not found\n";
exit(1);
}
FOO\SiteFinder::setSite($site);
echo "Creating new user\n";
$newuser = new FOO\User();
$newuser['name'] = FOO\Util::prompt("Username");
$newuser['real_name'] = FOO\Util::prompt("Real name");
$newuser->setPassword(FOO\Util::prompt("Password"));
$newuser['email'] = FOO\Util::prompt("Email");
$newuser['admin'] = strtolower(FOO\Util::prompt("Admin (y/n)")) === 'y';
$newuser['api_key'] = FOO\Random::base64_bytes(FOO\User::API_KEY_LEN);
$newuser->store();
printf("\nUser created! ID: %d\n", $newuser['id']);