认证检查每次页面重新加载 [英] Authentication Check each time the Page reloads

查看:153
本文介绍了认证检查每次页面重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个登录,根据角色保存在数据库中,将登录重定向到/ admin或/ user。但我有问题,如果有人登录为用户,并重定向到/用户,他可以在URL中键入/ admin,并被重定向到那里。所以我想我每次重新加载页面时都需要验证分配的角色。

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.

你们有什么提示吗?

推荐答案

除了一个 auth 过滤器, auth.admin 过滤器设置,将检查用户是否设置为管理员。如果没有,它将重定向到主页:代码

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

然后使用 auth.admin 过滤器集将所有管理路由添加到组中:

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
}

这篇关于认证检查每次页面重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆