Skip to content

Commit 9025f1f

Browse files
committed
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.
1 parent 046e915 commit 9025f1f

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

app/Console/Commands/MakeUser.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class MakeUser extends Command
3535
* @var string
3636
*/
3737
protected $signature = 'pterodactyl:user
38+
{--firstname= : First name to use for this account.}
39+
{--lastname= : Last name to use for this account.}
40+
{--username= : Username to use for this account.}
3841
{--email= : Email address to use for this account.}
3942
{--password= : Password to assign to the user.}
4043
{--admin= : Boolean flag for if user should be an admin.}';
@@ -63,19 +66,22 @@ public function __construct()
6366
*/
6467
public function handle()
6568
{
66-
$email = is_null($this->option('email')) ? $this->ask('Email') : $this->option('email');
67-
$password = is_null($this->option('password')) ? $this->secret('Password') : $this->option('password');
69+
$data['name_first'] = is_null($this->option('firstname')) ? $this->ask('First Name') : $this->option('firstname');
70+
$data['name_last'] = is_null($this->option('lastname')) ? $this->ask('Last Name') : $this->option('lastname');
71+
$data['username'] = is_null($this->option('username')) ? $this->ask('Username') : $this->option('username');
72+
$data['email'] = is_null($this->option('email')) ? $this->ask('Email') : $this->option('email');
73+
$data['password'] = is_null($this->option('password')) ? $this->secret('Password') : $this->option('password');
6874
$password_confirmation = is_null($this->option('password')) ? $this->secret('Confirm Password') : $this->option('password');
6975

70-
if ($password !== $password_confirmation) {
76+
if ($data['password'] !== $password_confirmation) {
7177
return $this->error('The passwords provided did not match!');
7278
}
7379

74-
$admin = is_null($this->option('admin')) ? $this->confirm('Is this user a root administrator?') : $this->option('admin');
80+
$data['root_admin'] = is_null($this->option('admin')) ? $this->confirm('Is this user a root administrator?') : $this->option('admin');
7581

7682
try {
7783
$user = new UserRepository;
78-
$user->create($email, $password, $admin);
84+
$user->create($data);
7985

8086
return $this->info('User successfully created.');
8187
} catch (\Exception $ex) {

app/Models/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
6767
*
6868
* @var [type]
6969
*/
70-
protected $fillable = ['username', 'email', 'name_first', 'name_last', 'password', 'language', 'use_totp', 'totp_secret', 'gravatar'];
70+
protected $fillable = ['username', 'email', 'name_first', 'name_last', 'password', 'language', 'use_totp', 'totp_secret', 'gravatar', 'root_admin'];
7171

7272
/**
7373
* Cast values to correct type.

app/Repositories/UserRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function create(array $data)
9090
'username' => $data['username'],
9191
'name_first' => $data['name_first'],
9292
'name_last' => $data['name_last'],
93-
'password' => Hash::make((empty($data['password'])) ? str_random(30) : $password),
93+
'password' => Hash::make((empty($data['password'])) ? str_random(30) : $data['password']),
9494
'root_admin' => $data['root_admin'],
9595
'language' => Settings::get('default_language', 'en'),
9696
]);

0 commit comments

Comments
 (0)