lundi 25 avril 2016

Redirect users to the log-in page if the session timeout in Laravel 5

I'm trying to redirect my users to the log-in page if the session timeout.

Here is my route

Route::get('/',['as' => 'login', 'uses'=>'AuthController@getSignIn']);

I've tried adding

    if ( $e instanceof \Illuminate\Session\TokenMismatchException ) {
        return redirect()->route('login');
    }

in render() in app/Exceptions/Handler.php

    public function render($request, Exception $e)
    {
        if ($e instanceof ModelNotFoundException) {
            $e = new NotFoundHttpException($e->getMessage(), $e);
        }

        if ( $e instanceof \Illuminate\Session\TokenMismatchException ) {
            return redirect()->route('login');
        }

        return parent::render($request, $e);
    }

That doesn't seem to take effect.

How do I implement this in Laravel ?

Any suggestions on this will be much helps !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire