File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed
Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Pterodactyl \Console \Commands ;
4+
5+ use Hash ;
6+ use Illuminate \Console \Command ;
7+
8+ use Pterodactyl \Repositories \UserRepository ;
9+
10+ class MakeUser extends Command
11+ {
12+ /**
13+ * The name and signature of the console command.
14+ *
15+ * @var string
16+ */
17+ protected $ signature = 'pterodactyl:user ' ;
18+
19+ /**
20+ * The console command description.
21+ *
22+ * @var string
23+ */
24+ protected $ description = 'Create a user within the panel. ' ;
25+
26+ /**
27+ * Create a new command instance.
28+ *
29+ * @return void
30+ */
31+ public function __construct ()
32+ {
33+ parent ::__construct ();
34+ }
35+
36+ /**
37+ * Execute the console command.
38+ *
39+ * @return mixed
40+ */
41+ public function handle ()
42+ {
43+ $ email = $ this ->ask ('Email ' );
44+ $ password = $ this ->secret ('Password ' );
45+ $ password_confirmation = $ this ->secret ('Confirm Password ' );
46+
47+ if ($ password !== $ password_confirmation ) {
48+ return $ this ->error ('The passwords provided did not match! ' );
49+ }
50+
51+ $ admin = $ this ->confirm ('Is this user a root administrator? ' );
52+
53+ try {
54+ $ user = new UserRepository ;
55+ $ user ->create ($ email , $ password , $ admin );
56+ return $ this ->info ('User successfully created. ' );
57+ } catch (\Exception $ ex ) {
58+ return $ this ->error ($ ex ->getMessage ());
59+ }
60+ }
61+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ class Kernel extends ConsoleKernel
1414 */
1515 protected $ commands = [
1616 \Pterodactyl \Console \Commands \Inspire::class,
17+ \Pterodactyl \Console \Commands \MakeUser::class,
1718 ];
1819
1920 /**
You can’t perform that action at this time.
0 commit comments