Get the response for a failed password reset.

@param  \Illuminate\Http\Request  $request
@param  string  $response
@return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
421295
protected function sendResetFailedResponse(Request $request, $response)
    {
        return redirect()->back()
                    ->withInput($request->only('email'))
                    ->withErrors(['email' => trans($response)]);
    }
135372
public function doFilter(Request $request, Response $response)
    {
        if ((int) $request->get('error') === 1) {
            return
                $response
                    ->withStatusCode(404)
                    ->write('error')
            ;
        }
    }
1060405
protected function response($response) {
    // Check for HTTP response error codes.
    if ($this->client->error) {
      $this->onErrorResponse(
        $this->client->errorCode,
        $this->client->errorMessage,
        $response
      );
    }
    else {
      $this->onSuccessfulResponse($response);
    }
    return $response;
  }
645112
public function sendResetLinkEmail(Request $request)
    {
        $this->validateEmail($request);

        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $request->only('email')
        );

        return $response == Password::RESET_LINK_SENT
            ? $this->sendResetLinkResponse($request, $response)
            : $this->sendResetLinkFailedResponse($request, $response);
    }
1267913
public function prepareResponse($request, $response)
    {
        if (! $response instanceof SymfonyResponse) {
            $response = new Response($response);
        }

        return $response->prepare($request);
    }
658998
public function postReset(Request $request)
    {
        $this->validate($request, [
            'token'         => 'required',
            'email'         => 'required|email',
            'password'      => 'required|confirmed|min:6',
        ]);

        // Here we will attempt to reset the user's password. If it is successful we
        // will update the password on an actual user model and persist it to the
        // database. Otherwise we will parse the error and return the response.
        $response = $this->broker()->reset(
            $this->credentials($request), function ($user, $password) {
                $this->resetPassword($user, $password);
            }
        );

        switch ($response) {
            case Password::PASSWORD_RESET:
                return $this->getResetSuccessResponse('pulsar::passwords.reset');

            default:
                return $this->getResetFailureResponse($request, $response);
        }
    }
492590
protected function sendVerificationFailedResponse(Request $request, $response)
    {
        return redirect($this->redirectPath())->with('error', trans($response));
    }
442851
protected function _redirect(ServerRequest $request, Response $response) {
		$message = $request->getSession()->consume($this->_config['flashKey']);
		$url = $response->getHeader('Location')[0];
		$status = $response->getStatusCode();

		$json = JsonEncoder::encode([
			// Error and content are here to make the output the same as previously
			// with the component, so existing unit tests don't break.
			'error' => null,
			'content' => null,
			'_message' => $message,
			'_redirect' => compact('url', 'status'),
		], $this->_config['jsonOptions']);

		$response = $response->withStatus(200)
			->withoutHeader('Location')
			->withHeader('Content-Type', 'application/json; charset=' . $response->getCharset())
			->withStringBody($json);

		return $response;
	}
1248642
public function getUserFromTokenResponse($response)
    {
        $user = $this->mapUserToObject($this->getUserByToken(
            $token = $this->parseAccessToken($response)
        ));

        $this->credentialsResponseBody = $response;

        if ($user instanceof User) {
            $user->setAccessTokenResponseBody($this->credentialsResponseBody);
        }

        return $user->setToken($token)
            ->setRefreshToken($this->parseRefreshToken($response))
            ->setExpiresIn($this->parseExpiresIn($response));
    }
442806
public function handleReset(string $reset_code = null, array $request = [])
    {
        if ($reset_code === null) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('login-page') . "?m=3");
            } else {
                return 'Redirect: ' . $this->router->generate('login-page') . "?m=3";
            }
        }
        $user = Model\User::where("reset_code", $reset_code)->first();
        if ($user === null) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('login-page') . "?m=3");
            } else {
                return 'Redirect: ' . $this->router->generate('login-page') . "?m=3";
            }
        }

        $validator = new \Valitron\Validator($request);
        $validator->rule('required', ['password', 'confirm_password']);
        $validator->rule(function ($field, $value, array $params, array $fields) {
            return is_string($value);
        }, ['password', 'confirm_password'])->message("{field} must be a string");
        $validator->rule('equals', 'confirm_password', 'password');
        $validator->rule('lengthBetween', 'password', 8, 80);
        if ($validator->validate() === false) {
            if (headers_sent() === false) {
                header('X-PHP-Response-Code: 422', true, 422);
            }
            return $this->templates->render("Auth::Reset", [
                "messages" => [
                    'error' => $validator->errors(),
                    'info' => '',
                    'success' => '',
                    'warning' => ''
                ]
            ]);
        }

        $response = $this->core->api('User/reset/' . $request['reset_code'], 'POST')->run($request);
        if (headers_sent() === false) {
            foreach ($response["headers"] as $header) {
                header($header[0], $header[1], $header[2]);
            }
        }
        if ($response["headers"][0][2] === 422) {
            return $this->templates->render("Auth::Reset", [
                "messages" => [
                    'error' => $response['response'],
                    'info' => '',
                    'success' => '',
                    'warning' => ''
                ],
                "reset_code" => $request['reset_code']
            ]);
        } elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('login-page') . "?m=4");
            } else {
                return 'Redirect: ' . $this->router->generate('login-page') . "?m=4";
            }
        } else {
            return $this->templates->render("500", [
                "error" => $response['response'],
                "result" => ''
            ]);
        }
    }
1214055
public function sendResetLinkEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email']);

        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $request->only('email')
        );
        if ($response === Password::RESET_LINK_SENT) {
            return back()->with('msg_success', 1);
        }

        // If an error was returned by the password broker, we will get this message
        // translated so we can notify a user of the problem. We'll redirect back
        // to where the users came from so they can attempt this process again.
        return back()->withErrors(
            ['email' => trans($response)]
        );
    }
468853
protected function checkResponse(Response $response)
    {
        $status = $response->getStatusCode();
        $reason = $response->getReasonPhrase();
        switch ($status) {
            case '403':
                throw new Exceptions\GeocodioAuthError($reason);
                break;

            case '422':
                throw new Exceptions\GeocodioDataError($reason);
                break;

            case '500':
                throw new Exceptions\GeocodioServerError($reason);
                break;

            case '200':
                return $response;
                break;

            default:
                throw new Exceptions\GeocodioException("There was a problem with your request - $reason");
                break;
        }
    }
1221556
protected function failureResponse($error = null)
    {
        if (request()->ajax()) {
            return response()->json([
                'success' => false,
                'error'   => $error,
            ]);
        }

        return redirect()->back()->withErrors([
            'general' => $error,
        ]);
    }
1145103
public function request(Request $request)
    {
        $user = User::whereEmail($request->email)->firstOrFail();
        $user->sendResetPasswordNotification($this->broker()->createToken($user), $request);

        return response()->json('Password request successful', 200);
    }
840598
function process_response($request, $response)
    {
        if (! isset($request->user) || $request->user->isAnonymous()) {
            return $response;
        }
        if ($request->user_space->touched) {
            if ($request->user_space->id > 0) {
                $request->user_space->update();
            } else {
                $request->user_space->create();
            }
        }
        return $response;
    }
1212914
protected function corsHandle($request, $response)
    {
        if (!$this->cors->hasAdded()) {
            $this->cors->setRequest('laravel', $request);
            $this->cors->setResponse('laravel', $response);
            $this->cors->handle();
        }

        return $this->cors->getResponse();
    }
1297688
public function resetPassword(Request $request)
    {
        $this->validate($request, [
            'password' => 'required|confirmed',
            'token'    => 'required'
       ]);

        $record= $this->resetPasswordRepo->where('token', $request['token']);
        $email = $record->first()->email;
        $record->delete();

        $user = $this->userRepo->where('email', $email)->update(['password' => $request['password']]);
        return redirect()->route('core::home');
    }