@Route("/{id}/redirect", name="victoire_404_redirect")

@Method("POST")

@param Request  $request
@param Error404 $error404

@return JsonResponse|Response
353467
public function redirectAction(Request $request, Error404 $error404)
    {
        $redirection = new ErrorRedirection();
        $redirection->setError($error404);

        $form = $this->getError404RedirectionForm($redirection);
        $form->handleRequest($request);

        if ($request->query->get('novalidate', false) === false) {
            if ($form->isValid()) {
                if ($redirection->getLink()->getLinkType() !== Link::TYPE_NONE) {
                    $error404->setRedirection($redirection);
                    $redirection->setError($error404);
                    $redirection->setUrl($error404->getUrl());

                    $em = $this->getDoctrine()->getManager();
                    $em->persist($redirection);
                    $em->flush();

                    $this->congrat($this->get('translator')->trans('victoire.404.redirection.success'));

                    return $this->returnAfterRemoval($error404);
                }

                $form->addError(new FormError($this->get('translator')->trans('victoire.404.form.error.blank')));
            }

            $this->warn($this->get('translator')->trans('victoire.404.form.error.unvalid'));

            return new Response($this->renderView('@VictoireSeo/Error404/_list.html.twig', [
                'form'     => $form->createView(),
                'error'    => $error404,
                'isOpened' => true,
            ]), 200, [
                'X-Inject-Alertify' => true,
            ]);
        }

        // rebuild form to avoid wrong form error
        $form = $this->getError404RedirectionForm($redirection);

        return new JsonResponse([
            'html' => $this->renderView('@VictoireSeo/Error404/_list.html.twig', [
                'form'     => $form->createView(),
                'error'    => $error404,
                'isOpened' => true,
            ]),
        ]);
    }
437895
public function handleError($redirection, $error404)
    {
        if ($redirection) {
            $this->increaseCounter($redirection);

            return $redirection;
        } elseif ($error404) {
            $this->increaseCounter($error404);

            return $error404;
        }

        throw new NoResultException();
    }
1043785
protected function sendFailedLoginResponse( Request $request )
	{
		return Redirect::back()->withInput( $request->only( $this->loginUsername(), 'remember' ) )->withErrors( [
				$this->loginUsername() => $this->getFailedLoginMessage(),
			] );
	}
79227
public function importAction(Request $request)
    {
        if (!$request->files->has('redirectRoutes')) {
            return new JsonResponse(null, Response::HTTP_BAD_REQUEST);
        }

        /** @var UploadedFile $uploadedFile */
        $uploadedFile = $request->files->get('redirectRoutes');
        $file = $uploadedFile->move(
            $this->importPath,
            $uploadedFile->getClientOriginalName()
        );

        try {
            return new JsonResponse($this->importFile($file));
        } catch (ReaderNotFoundException $exception) {
            return new JsonResponse(null, Response::HTTP_BAD_REQUEST);
        } catch (ConverterNotFoundException $exception) {
            return new JsonResponse(null, Response::HTTP_BAD_REQUEST);
        }
    }
987708
public function getRedirectFor(Request $request)
    {
        $potentialRules = $this->getPotentialRules($request->path());

        // Make route for each of potential rules and let Laravel handle the rest
        $potentialRules->each(function ($redirect) {
            $this->router->get($redirect->origin, function () use ($redirect) {
                $destination = $this->resolveDestination($redirect->destination);

                return redirect($destination, $redirect->status_code);
            });
        });

        // If one of the routes could be dispatched it means
        // we have a match in database and we can continue with redirection
        // (from callback above)
        try {
            return $this->router->dispatch($request);
        } catch (Exception $e) {
            return null;
        }
    }
1009447
public function postLogin(\Illuminate\Http\Request $request)
	{
		$this->validate($request, [
			'username' => 'required', 'password' => 'required',
		], [ 
			'required' => trans('common::admin.validation.required')
		]);
		
		$return_url = $request->input('return_url', '');
		if ($return_url == '') $return_url = null;

		$credentials = $request->only('username', 'password');
		
		if ($this->auth->attempt($credentials, $request->has('remember')))
		{
			if ($request->ajax())
			{
				return [ 'success' => true, 'token' => csrf_token() ];
			}
			
			return ($return_url != null ? redirect($return_url) : redirect()->route('admin-home'));
		}
		
		if ($request->ajax() || $request->wantsJson())
		{
			throw new \Illuminate\Http\Exception\HttpResponseException(
				new \Illuminate\Http\JsonResponse([ 'username' => 'Wrong username or password' ], 422)
			);
		}
		
		return redirect(route('admin-login') . '?return_url=' . urlencode($return_url))
			->withInput($request->only('username', 'remember'))
			->withErrors([
				'username' => 'Wrong username or password',
			]);
	}
1341171
public function resolve(Request $request) : Response {
        if($request->expectsJson()) {
            return $this->json();
        }

        return $this->redirect();
    }
1156183
protected function sendFailedLoginResponse(Request $request)
    {
        return redirect()->back()
            ->withInput($request->only($this->username(), 'remember'))
            ->withErrors([
                $this->username() => Lang::get('auth.failed'),
            ]);
    }
1028032
public function postRemind(Request $request)
    {

        $form = FormBuilder::create('Distilleries\Expendable\Http\Forms\Login\Forgotten');
        if ($form->hasError())
        {
            return $form->validateAndRedirectBack();
        }

        $this->validate($request, ['email' => 'required|email']);
        
        $response = $this->broker()->sendResetLink($request->only('email'));

        switch ($response)
        {
            case \Password::RESET_LINK_SENT:
                return redirect()->back()->with(Message::MESSAGE, [trans($response)]);
            default:
                return redirect()->back()->with(Message::WARNING, [trans($response)]);
        }

    }
438902
public function postRegister(Request $request)
    {
        $credentials = $request->only(['mobile', 'password']);

        $validator = Validator::make($credentials, [
            'mobile' => 'required', 'password' => 'required',
        ]);

        if ($validator->fails()) {
            return Redirect::back()->withInput()->withErrors($validator);
        }


        //这儿需要重写

        return Redirect::back()->withInput()->withErrors(['mobile' => $this->getFailedLoginMessage()]);
    }
432059
protected function getRedirectRoute(Request $request, $url)
    {
        // redirect to linked page
        return new Route(
            $this->decodePathInfo($request->getPathInfo()),
            [
                '_controller' => 'SuluWebsiteBundle:Redirect:redirect',
                'url' => $url,
            ]
        );
    }
399130
public function store(Request $request)
    {
        $data = $this->validate(request(), [
            'old_url' => 'required',
            'new_url' => 'required'
        ]);

        Redirection::create($data);

        session()->flash('success', 'Redirección registrada con éxito!');
        return redirect()->route('redirecciones.index');
    }
663505
public function postRegister(Request $request)
	{
		$validator = $this->registrar->validator($request->all());

		if ($validator->fails())
		{
			$this->throwValidationException(
				$request, $validator
			);
		}

		$this->auth->login($this->registrar->create($request->all()));

		return redirect($this->redirectPath());
	}
666669
public function postAction(Request $request)
    {
        $data = $request->request->all();

        $serializer = $this->get('serializer');
        $redirectRoute = $serializer->deserialize(
            json_encode($data),
            $this->getParameter('sulu.model.redirect_route.class'),
            'json'
        );

        $this->getRedirectRouteManager()->save($redirectRoute);
        $this->get('doctrine.orm.entity_manager')->flush();

        return $this->handleView($this->view($redirectRoute));
    }
1134308
protected function _buildLoginUrlErrorResult($request)
    {
        $errors = [
            sprintf(
                'Login URL `%s` did not match `%s`.',
                (string)$request->getUri(),
                implode('` or `', (array)$this->getConfig('loginUrl'))
            )
        ];

        return new Result(null, Result::FAILURE_OTHER, $errors);
    }
1041481
protected function redirectTo(Request $request, $to)
    {
		if ($request->headers->get('X-REQUESTED-WITH') == 'XMLHttpRequest') {
			return $this->render('VivaitBootstrapBundle:Default:redirect.html.twig', array(
				'redirect' => $to
			));
		}

		return $this->redirect($to);
	}
81957
private function returnAfterRemoval(Error404 $error404)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var HttpErrorRepository $errorRepository */
        $errorRepository = $em->getRepository('VictoireSeoBundle:HttpError');

        $errors = ($error404->getType() == HttpError::TYPE_ROUTE)
            ? $errorRepository->getRouteErrors()
            : $errorRepository->getFileErrors();

        if (0 == count($errors->getQuery()->getResult())) {
            return new Response($this->renderView('@VictoireSeo/Error404/_empty.html.twig'), 200, [
                'X-Inject-Alertify' => true,
            ]);
        }

        return new Response(null, 200, [
            'X-VIC-Remove'      => '100ms',
            'X-Inject-Alertify' => true,
        ]);
    }