Conditions | 3 |
Paths | 2 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public function handle(): void |
||
23 | { |
||
24 | /** @var User $user */ |
||
25 | $user = User::where('is_admin', true)->first(); |
||
26 | |||
27 | if (!$user) { |
||
|
|||
28 | $this->error('An admin account cannot be found. Have you set up Koel yet?'); |
||
29 | |||
30 | return; |
||
31 | } |
||
32 | |||
33 | $this->comment("Changing the default admin's password (ID: {$user->id}, email: {$user->email})"); |
||
34 | |||
35 | do { |
||
36 | $password = $this->secret('New password'); |
||
37 | $confirmedPassword = $this->secret('Again, just to be sure'); |
||
38 | } while (!$this->validatePasswords($password, $confirmedPassword)); |
||
39 | |||
40 | $user->password = $this->hash->make($password); |
||
41 | $user->save(); |
||
42 | |||
43 | $this->comment('New password saved, enjoy! 👌'); |
||
44 | } |
||
63 |