Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restricting access to a page if user isn't logged in with Laravel 5.4

Tags:

laravel

I've created a Dashboard page and i want it to be accessed only if an user is logged in. The login and register were made with the php artisan make:auth command. Any tips or ideas how to accomplish this ?

like image 838
CoffeeGuy Avatar asked Dec 14 '22 23:12

CoffeeGuy


1 Answers

Just add the Auth middleware to your route

Route::get('dashboard', function () {
    //whatever
})->middleware('auth');

Make sure you have

use Auth; in your routes

like image 110
Mihai Avatar answered Apr 27 '23 00:04

Mihai