如果使用Gate授权失败,则Laravel重定向

问题描述

在我的应用程序中,我正在使用gates来验证登录用户的authorization。我希望使用自定义消息将用户重定向到仪表板,而不是显示传统的403 | This action is unauthorized.页面。

这是我的代码:

class SomeController extends Controller
{
    public function index()
    {
        # access
        if(!$this->authorize('some-role'))
        {
            session->set('message','message');

            return redirect()->route(...);
        }

        ...
    }
}

这可能吗??

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)