如果用户未使用Laravel 5.4登录,则限制对页面的访问 [英] Restricting access to a page if user isn't logged in with Laravel 5.4
本文介绍了如果用户未使用Laravel 5.4登录,则限制对页面的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个Dashboard页面,并且我希望只有在用户登录后才能访问它.登录和注册是使用php artisan make:auth
命令进行的.有什么技巧或想法如何做到这一点?
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 ?
推荐答案
只需将Auth中间件添加到您的路由
Just add the Auth middleware to your route
Route::get('dashboard', function () {
//whatever
})->middleware('auth');
确保您拥有
use Auth;
在您的路线中
这篇关于如果用户未使用Laravel 5.4登录,则限制对页面的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文