Repair user creation functionality

Repair functionality of the make user console command (pterodactyl:user)
Fix up the user repository, was using the old $password instead of the changed format $data['password']
Change User model to allow root_admin to be a fillable item.
This commit is contained in:
Emmet Young 2017-01-23 00:47:09 +11:00
parent 046e9152eb
commit 9025f1f583
3 changed files with 13 additions and 7 deletions

View file

@ -35,6 +35,9 @@ class MakeUser extends Command
* @var string
*/
protected $signature = 'pterodactyl:user
{--firstname= : First name to use for this account.}
{--lastname= : Last name to use for this account.}
{--username= : Username to use for this account.}
{--email= : Email address to use for this account.}
{--password= : Password to assign to the user.}
{--admin= : Boolean flag for if user should be an admin.}';
@ -63,19 +66,22 @@ class MakeUser extends Command
*/
public function handle()
{
$email = is_null($this->option('email')) ? $this->ask('Email') : $this->option('email');
$password = is_null($this->option('password')) ? $this->secret('Password') : $this->option('password');
$data['name_first'] = is_null($this->option('firstname')) ? $this->ask('First Name') : $this->option('firstname');
$data['name_last'] = is_null($this->option('lastname')) ? $this->ask('Last Name') : $this->option('lastname');
$data['username'] = is_null($this->option('username')) ? $this->ask('Username') : $this->option('username');
$data['email'] = is_null($this->option('email')) ? $this->ask('Email') : $this->option('email');
$data['password'] = is_null($this->option('password')) ? $this->secret('Password') : $this->option('password');
$password_confirmation = is_null($this->option('password')) ? $this->secret('Confirm Password') : $this->option('password');
if ($password !== $password_confirmation) {
if ($data['password'] !== $password_confirmation) {
return $this->error('The passwords provided did not match!');
}
$admin = is_null($this->option('admin')) ? $this->confirm('Is this user a root administrator?') : $this->option('admin');
$data['root_admin'] = is_null($this->option('admin')) ? $this->confirm('Is this user a root administrator?') : $this->option('admin');
try {
$user = new UserRepository;
$user->create($email, $password, $admin);
$user->create($data);
return $this->info('User successfully created.');
} catch (\Exception $ex) {