]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/Auth/ResetPasswordController.php
Update Localization.php in Middleware with "no" tag for estimate.
[bookstack] / app / Http / Controllers / Auth / ResetPasswordController.php
1 <?php
2
3 namespace BookStack\Http\Controllers\Auth;
4
5 use BookStack\Http\Controllers\Controller;
6 use Illuminate\Foundation\Auth\ResetsPasswords;
7 use Illuminate\Http\Request;
8 use Illuminate\Support\Facades\Password;
9
10 class ResetPasswordController extends Controller
11 {
12     /*
13     |--------------------------------------------------------------------------
14     | Password Reset Controller
15     |--------------------------------------------------------------------------
16     |
17     | This controller is responsible for handling password reset requests
18     | and uses a simple trait to include this behavior. You're free to
19     | explore this trait and override any methods you wish to tweak.
20     |
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         parent::__construct();
37     }
38
39     /**
40      * Get the response for a successful password reset.
41      *
42      * @param Request $request
43      * @param string $response
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         return redirect($this->redirectPath())
51             ->with('status', trans($response));
52     }
53
54     /**
55      * Get the response for a failed password reset.
56      *
57      * @param  \Illuminate\Http\Request  $request
58      * @param  string  $response
59      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
60      */
61     protected function sendResetFailedResponse(Request $request, $response)
62     {
63         // We show invalid users as invalid tokens as to not leak what
64         // users may exist in the system.
65         if ($response === Password::INVALID_USER) {
66             $response = Password::INVALID_TOKEN;
67         }
68
69         return redirect()->back()
70             ->withInput($request->only('email'))
71             ->withErrors(['email' => trans($response)]);
72     }
73 }