| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-11 02:31:09 +08:00
										 |  |  | namespace BookStack\Http\Controllers\Auth; | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-21 03:33:11 +08:00
										 |  |  | use BookStack\Actions\ActivityType; | 
					
						
							| 
									
										
										
										
											2015-09-11 02:31:09 +08:00
										 |  |  | use BookStack\Http\Controllers\Controller; | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  | use Illuminate\Foundation\Auth\ResetsPasswords; | 
					
						
							| 
									
										
										
										
											2019-09-07 06:36:16 +08:00
										 |  |  | use Illuminate\Http\Request; | 
					
						
							| 
									
										
										
										
											2020-04-10 20:38:08 +08:00
										 |  |  | use Illuminate\Support\Facades\Password; | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-18 01:22:04 +08:00
										 |  |  | class ResetPasswordController extends Controller | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     /* | 
					
						
							|  |  |  |     |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |     | Password Reset Controller | 
					
						
							|  |  |  |     |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |     | | 
					
						
							|  |  |  |     | This controller is responsible for handling password reset requests | 
					
						
							|  |  |  |     | and uses a simple trait to include this behavior. You're free to | 
					
						
							|  |  |  |     | explore this trait and override any methods you wish to tweak. | 
					
						
							|  |  |  |     | | 
					
						
							|  |  |  |     */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     use ResetsPasswords; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-12 19:40:54 +08:00
										 |  |  |     protected $redirectTo = '/'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2016-09-18 01:22:04 +08:00
										 |  |  |      * Create a new controller instance. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function __construct() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->middleware('guest'); | 
					
						
							| 
									
										
										
										
											2020-02-02 21:10:21 +08:00
										 |  |  |         $this->middleware('guard:standard'); | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-11-12 19:40:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get the response for a successful password reset. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2019-09-07 06:36:16 +08:00
										 |  |  |      * @param Request $request | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  |      * @param string  $response | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-11-12 19:40:54 +08:00
										 |  |  |      * @return \Illuminate\Http\Response | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2019-09-07 06:36:16 +08:00
										 |  |  |     protected function sendResetResponse(Request $request, $response) | 
					
						
							| 
									
										
										
										
											2016-11-12 19:40:54 +08:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-12-05 00:51:39 +08:00
										 |  |  |         $message = trans('auth.reset_password_success'); | 
					
						
							| 
									
										
										
										
											2019-10-05 19:55:01 +08:00
										 |  |  |         $this->showSuccessNotification($message); | 
					
						
							| 
									
										
										
										
											2020-11-21 03:33:11 +08:00
										 |  |  |         $this->logActivity(ActivityType::AUTH_PASSWORD_RESET_UPDATE, user()); | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-12 19:40:54 +08:00
										 |  |  |         return redirect($this->redirectPath()) | 
					
						
							|  |  |  |             ->with('status', trans($response)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-10 20:38:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get the response for a failed password reset. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  |      * @param \Illuminate\Http\Request $request | 
					
						
							|  |  |  |      * @param string                   $response | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2020-04-10 20:38:08 +08:00
										 |  |  |      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     protected function sendResetFailedResponse(Request $request, $response) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // We show invalid users as invalid tokens as to not leak what
 | 
					
						
							|  |  |  |         // users may exist in the system.
 | 
					
						
							|  |  |  |         if ($response === Password::INVALID_USER) { | 
					
						
							|  |  |  |             $response = Password::INVALID_TOKEN; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return redirect()->back() | 
					
						
							|  |  |  |             ->withInput($request->only('email')) | 
					
						
							|  |  |  |             ->withErrors(['email' => trans($response)]); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-01-29 00:58:52 +08:00
										 |  |  | } |