Search code examples
laravel-8laravel-jetstream

Laravel 8 Jetstream how to redirect user to custom route after resetting password


I am using Laravel 8 jetstream for authentication. My question is, how can I redirect the user after resetting the password to the custom route? I don't want to redirect the user to the login page. I didn't find the route in all Fortify classes; I am sure it should override.

protected $redirectTo

But I don't know in which file I have to do this change.


Solution

  • EDIT: It is not recommended to edit a file in vendor, use BillD's solution.

    Check out vendor\laravel\fortify\src\Http\Responses\PasswordResetResponse.php

    You should be able to modify the response in the method:

    /**
         * Create an HTTP response that represents the object.
         *
         * @param  \Illuminate\Http\Request  $request
         * @return \Symfony\Component\HttpFoundation\Response
         */
        public function toResponse($request)
        {
            return $request->wantsJson()
                        ? new JsonResponse(['message' => trans($this->status)], 200)
                        : redirect()->route('login')->with('status', trans($this->status));
        }