Changeset View
Changeset View
Standalone View
Standalone View
scripts/user/account_admin.php
| Show All 15 Lines | echo pht( | ||||
| "WARNING\n\n". | "WARNING\n\n". | ||||
| "You're about to create the first account on this install. Normally, you ". | "You're about to create the first account on this install. Normally, you ". | ||||
| "should use the web interface to create the first account, not this ". | "should use the web interface to create the first account, not this ". | ||||
| "script.\n\n". | "script.\n\n". | ||||
| "If you use the web interface, it will drop you into a nice UI workflow ". | "If you use the web interface, it will drop you into a nice UI workflow ". | ||||
| "which gives you more help setting up your install. If you create an ". | "which gives you more help setting up your install. If you create an ". | ||||
| "account with this script instead, you will skip the setup help and you ". | "account with this script instead, you will skip the setup help and you ". | ||||
| "will not be able to access it later."); | "will not be able to access it later."); | ||||
| if (!phutil_console_confirm(pht("Skip easy setup and create account?"))) { | if (!phutil_console_confirm(pht('Skip easy setup and create account?'))) { | ||||
| echo pht("Cancelled.")."\n"; | echo pht('Cancelled.')."\n"; | ||||
| exit(1); | exit(1); | ||||
| } | } | ||||
| } | } | ||||
| echo "Enter a username to create a new account or edit an existing account."; | echo 'Enter a username to create a new account or edit an existing account.'; | ||||
| $username = phutil_console_prompt("Enter a username:"); | $username = phutil_console_prompt('Enter a username:'); | ||||
| if (!strlen($username)) { | if (!strlen($username)) { | ||||
| echo "Cancelled.\n"; | echo "Cancelled.\n"; | ||||
| exit(1); | exit(1); | ||||
| } | } | ||||
| if (!PhabricatorUser::validateUsername($username)) { | if (!PhabricatorUser::validateUsername($username)) { | ||||
| $valid = PhabricatorUser::describeValidUsername(); | $valid = PhabricatorUser::describeValidUsername(); | ||||
| echo "The username '{$username}' is invalid. {$valid}\n"; | echo "The username '{$username}' is invalid. {$valid}\n"; | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
| // When creating a new user we prompt for an email address; when editing an | // When creating a new user we prompt for an email address; when editing an | ||||
| // existing user we just skip this because it would be quite involved to provide | // existing user we just skip this because it would be quite involved to provide | ||||
| // a reasonable CLI interface for editing multiple addresses and managing email | // a reasonable CLI interface for editing multiple addresses and managing email | ||||
| // verification and primary addresses. | // verification and primary addresses. | ||||
| $create_email = null; | $create_email = null; | ||||
| if ($is_new) { | if ($is_new) { | ||||
| do { | do { | ||||
| $email = phutil_console_prompt("Enter user email address:"); | $email = phutil_console_prompt('Enter user email address:'); | ||||
| $duplicate = id(new PhabricatorUserEmail())->loadOneWhere( | $duplicate = id(new PhabricatorUserEmail())->loadOneWhere( | ||||
| 'address = %s', | 'address = %s', | ||||
| $email); | $email); | ||||
| if ($duplicate) { | if ($duplicate) { | ||||
| echo "ERROR: There is already a user with that email address. ". | echo "ERROR: There is already a user with that email address. ". | ||||
| "Each user must have a unique email address.\n"; | "Each user must have a unique email address.\n"; | ||||
| } else { | } else { | ||||
| break; | break; | ||||
| } | } | ||||
| } while (true); | } while (true); | ||||
| $create_email = $email; | $create_email = $email; | ||||
| } | } | ||||
| $changed_pass = false; | $changed_pass = false; | ||||
| // This disables local echo, so the user's password is not shown as they type | // This disables local echo, so the user's password is not shown as they type | ||||
| // it. | // it. | ||||
| phutil_passthru('stty -echo'); | phutil_passthru('stty -echo'); | ||||
| $password = phutil_console_prompt( | $password = phutil_console_prompt( | ||||
| "Enter a password for this user [blank to leave unchanged]:"); | 'Enter a password for this user [blank to leave unchanged]:'); | ||||
| phutil_passthru('stty echo'); | phutil_passthru('stty echo'); | ||||
| if (strlen($password)) { | if (strlen($password)) { | ||||
| $changed_pass = $password; | $changed_pass = $password; | ||||
| } | } | ||||
| $is_system_agent = $user->getIsSystemAgent(); | $is_system_agent = $user->getIsSystemAgent(); | ||||
| $set_system_agent = phutil_console_confirm( | $set_system_agent = phutil_console_confirm( | ||||
| 'Is this user a bot/script?', | 'Is this user a bot/script?', | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| printf( | printf( | ||||
| $tpl, | $tpl, | ||||
| 'Admin', | 'Admin', | ||||
| $original->getIsAdmin() ? 'Y' : 'N', | $original->getIsAdmin() ? 'Y' : 'N', | ||||
| $set_admin ? 'Y' : 'N'); | $set_admin ? 'Y' : 'N'); | ||||
| echo "\n"; | echo "\n"; | ||||
| if (!phutil_console_confirm("Save these changes?", $default_no = false)) { | if (!phutil_console_confirm('Save these changes?', $default_no = false)) { | ||||
| echo "Cancelled.\n"; | echo "Cancelled.\n"; | ||||
| exit(1); | exit(1); | ||||
| } | } | ||||
| $user->openTransaction(); | $user->openTransaction(); | ||||
| $editor = new PhabricatorUserEditor(); | $editor = new PhabricatorUserEditor(); | ||||
| Show All 32 Lines | |||||