Authentication Check each time the Page reloads

a 夏天 提交于 2019-12-13 05:15:23

问题


I have a Login which redirects you to '/admin' or '/user' depending on which role is saved in the Database. But I have the problem if someone logs in as User and gets redirected to '/user' he can type '/admin' in the URL and gets redirected there. So I guess I need a validation of the assigned role everytime the Page reloads.

Do you guys have any tips on that?


回答1:


In addition to just an auth filter, I also have an auth.admin filter set up that will check to see if the user is set to an admin. If not, it will redirect to the home page: code

Then add all of your admin routes into a group with the auth.admin filter set:

Route::group(array('prefix' => 'admin', 'before' => 'auth.admin'), function()
{
    // admin routes here
}


来源:https://stackoverflow.com/questions/25686141/authentication-check-each-time-the-page-reloads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!