samedi 2 mai 2020

Route redirection is not working in Laravel

After successfully login in my Laravel application, it takes me to dashbaord. After logout from the application it takes me to the login page again. But if I click back icon from the browser It will take me to dashboard again though I have log out.

routes

Route::get('/admin-login', 'userController@index');
Route::post('/admin-login', 'userController@admin_login');
Route::get('/admin-logout', 'userController@admin_logout');
Route::get('/dashboard', 'dashboardController@index');

dashboardController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class dashboardController extends Controller
{
    public function __construct()
    {
        if (!Auth::check()) {
            return redirect('/admin-login'); //This Redirection Doesn't Work
        }
    }

    public function index()
    {
        return view('admin.dashboard.dashboard');
    }
}

Where is the problem I can't find out. Please Anybody help ? Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire