]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/Auth/ResetPasswordController.php
Cleaned testing service provider usage
[bookstack] / app / Http / Controllers / Auth / ResetPasswordController.php
1 <?php
2
3 namespace BookStack\Http\Controllers\Auth;
4
5 use BookStack\Actions\ActivityType;
6 use BookStack\Http\Controllers\Controller;
7 use Illuminate\Foundation\Auth\ResetsPasswords;
8 use Illuminate\Http\Request;
9 use Illuminate\Support\Facades\Password;
10
11 class ResetPasswordController extends Controller
12 {
13     /*
14     |--------------------------------------------------------------------------
15     | Password Reset Controller
16     |--------------------------------------------------------------------------
17     |
18     | This controller is responsible for handling password reset requests
19     | and uses a simple trait to include this behavior. You're free to
20     | explore this trait and override any methods you wish to tweak.
21     |
22     */
23     use ResetsPasswords;
24
25     protected $redirectTo = '/';
26
27     /**
28      * Create a new controller instance.
29      *
30      * @return void
31      */
32     public function __construct()
33     {
34         $this->middleware('guest');
35         $this->middleware('guard:standard');
36     }
37
38     /**
39      * Get the response for a successful password reset.
40      *
41      * @param Request $request
42      * @param string  $response
43      *
44      * @return \Illuminate\Http\Response
45      */
46     protected function sendResetResponse(Request $request, $response)
47     {
48         $message = trans('auth.reset_password_success');
49         $this->showSuccessNotification($message);
50         $this->logActivity(ActivityType::AUTH_PASSWORD_RESET_UPDATE, user());
51
52         return redirect($this->redirectPath())
53             ->with('status', trans($response));
54     }
55
56     /**
57      * Get the response for a failed password reset.
58      *
59      * @param \Illuminate\Http\Request $request
60      * @param string                   $response
61      *
62      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
63      */
64     protected function sendResetFailedResponse(Request $request, $response)
65     {
66         // We show invalid users as invalid tokens as to not leak what
67         // users may exist in the system.
68         if ($response === Password::INVALID_USER) {
69             $response = Password::INVALID_TOKEN;
70         }
71
72         return redirect()->back()
73             ->withInput($request->only('email'))
74             ->withErrors(['email' => trans($response)]);
75     }
76 }