Php 自定义路由筛选器忽略重定向

Php 自定义路由筛选器忽略重定向,php,laravel,laravel-4,laravel-routing,Php,Laravel,Laravel 4,Laravel Routing,我在尝试创建自定义筛选器时遇到一些问题。我的目标是确保经过身份验证的用户在允许他们访问组中定义的路由之前满足特定条件 现在它只是继续/页没有问题,即使我已经确认其中一个条件已经满足。它忽略了我的重定向 routes.php Route::group(array('before' => 'registered'), function() { Route::get('/page', array('as' => 'page', 'uses' => 'PageControlle

我在尝试创建自定义筛选器时遇到一些问题。我的目标是确保经过身份验证的用户在允许他们访问组中定义的路由之前满足特定条件

现在它只是继续/页没有问题,即使我已经确认其中一个条件已经满足。它忽略了我的重定向

routes.php

Route::group(array('before' => 'registered'), function()
{
    Route::get('/page', array('as' => 'page', 'uses' => 'PageController@getIndex'));
});
filters.php

Route::filter('registered', function()
{
    if(Auth::check())
    {
        if(!Auth::user()->confirmed())
        {
            return Redirect::route('signup.send.confirmation')->with('alert-warning', 'You must confirm your email address before continuing.  Fill out the form below if you need a new activation email.  Thank you!');
        }

        if(!Auth::user()->registered)
        {
            return Redirect::route('signup.profile')->with('alert-warning', 'You must fill out the following information before continuing.  Thank you!');
        }
    }
});

非常感谢您的帮助!谢谢大家!

我认为你的过滤器有问题。您似乎允许未注册的用户访问此路由。我想你需要的是:

Route::filter('registered', function()
{
    if(!Auth::check()) {
          return Redirect::route('signup.profile')->with('alert-warning', 'You must fill out the following information before continuing.  Thank you!');
    }

    else
    {
        if(!Auth::user()->confirmed())
        {
            return Redirect::route('signup.send.confirmation')->with('alert-warning', 'You must confirm your email address before continuing.  Fill out the form below if you need a new activation email.  Thank you!');
        }
    }
});

如果无法解决问题,则应提供更多详细信息,尤其是如何检查这些条件是否为真,以及是否确实运行了此筛选器

我不知道如何解释它,但现在它正按照我原来的帖子所写的那样工作。我一定是忽略了某个地方的考试

访问/页面不需要身份验证。但是如果他们经过身份验证,我想确保他们已经完成了创建完整帐户/配置文件所需的所有步骤。这就是过滤器的理由,如果它们没有经过身份验证,它不会重定向它们

如果你想做一个自定义的过滤器,我的原始问题的作品!对不起,浪费了大家的时间