Conditions | 3 |
Paths | 0 |
Total Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | public function handle() |
||
28 | { |
||
29 | $users = Administrator::all(); |
||
30 | |||
31 | askForUserName: |
||
32 | $username = $this->askWithCompletion('Please enter a username who needs to reset his password', $users->pluck('username')->toArray()); |
||
33 | |||
34 | $user = $users->first(function ($user) use ($username) { |
||
35 | return $user->username == $username; |
||
36 | }); |
||
37 | |||
38 | if (is_null($user)) { |
||
39 | $this->error('The user you entered is not exists'); |
||
40 | goto askForUserName; |
||
41 | } |
||
42 | |||
43 | enterPassword: |
||
44 | $password = $this->secret('Please enter a password'); |
||
45 | |||
46 | if ($password !== $this->secret('Please confirm the password')) { |
||
47 | $this->error('The passwords entered twice do not match, please re-enter'); |
||
48 | goto enterPassword; |
||
49 | } |
||
50 | |||
51 | $user->password = bcrypt($password); |
||
52 | |||
53 | $user->save(); |
||
54 | |||
55 | $this->info('User password reset successfully.'); |
||
56 | } |
||
57 | } |