Conditions | 2 |
Paths | 2 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public function __invoke(FinishSetupRequest $request) |
||
22 | { |
||
23 | $link = UserInitialize::where('username', $request->username)->firstOrFail(); |
||
24 | |||
25 | // Determine the new expiration date |
||
26 | $expires = config('auth.passwords.settings.expire') ? Carbon::now()->addDays(config('auth.passwords.settings.expire')) : null; |
||
27 | |||
28 | // Set the users new password |
||
29 | $user = User::where('username', $request->username)->firstOrFail(); |
||
30 | $user->update(['password' => Hash::make($request->password), 'password_expires' => $expires]); |
||
31 | $user->save(); |
||
32 | |||
33 | // Delete the Initialization Link |
||
34 | $link->delete(); |
||
35 | |||
36 | // Log the user in and send to the Dashboard |
||
37 | Auth::login($user); |
||
38 | |||
39 | event(new UserInitializedEvent($user)); |
||
40 | return redirect(route('dashboard'))->with([ |
||
41 | 'message' => 'Your Account is setup', |
||
42 | 'type' => 'success', |
||
43 | ]); |
||
46 |