Configuring redirection in laravel 5.5

Posted 4 months ago by daniel21gt

so, today I tried to perform a redirect, I pretend that when the session time expires, I automatically redirected to the login path, and not to this path (\ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Exceptions \ views \ 419.blade.php

I have done this in the handler, but it does not work, it keeps getting there.

* @param  \Exception  $exception
 * @return void
 */
public function report(Exception $exception)
{
    parent::report($exception);
}

/**
 * Render an exception into an HTTP response.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Exception  $exception
 * @return \Illuminate\Http\Response
 */
public function render($request, Exception $exception)
{
    
      if($this->isHttpException($exception))
    {
        switch ($exception->getStatusCode()) {
            //access denied
            case 401:
                return response()->view('usuario.error', [], 401);  
            break;
            // not found
            case 404:
                return response()->view('usuario.error', [], 404);
            break;
            // internal error
            case 403:
                return response()->view('usuario.error', [], 403);  
            break;
            // internal error
            case 500:
                return response()->view('usuario.error', [], 500);  
            break;
              // internal error
            case 405:
                return redirect()->route('login');
            break;
            // internal error
            case 419:
                return redirect()->route('login');
            break;

            default:
                return $this->renderHttpException($exception);
            break;
        }
    }
    else
    {
        return parent::render($request, $exception);
    }

}

What can I do to achieve this?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.