Laravel bug中间件

时间:2016-08-08 20:07:08

标签: php laravel laravel-middleware

我把dd($next)用于我的中间件调试(VerifyCsrfToken.php):

public function handle($request, Closure $next)
{
    dd($next);
    // Add this:
    if($request->method() == 'POST')
    {
        return $next($request);
    }

    if ($request->method() == 'GET' || $this->tokensMatch($request))
    {
        return $next($request);
    }

    throw new TokenMismatchException;
}

我删除了它,但现在我的应用程序中总是显示TRUE,仅此而已。我删除了缓存,让作曲家自动加载...

修改

完整代码:

    <?php namespace App\Http\Middleware;

use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

use Exception;

class TokenMismatchException extends Exception {}

class VerifyCsrfToken extends BaseVerifier {

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */



    /*public function handle($request, Closure $next)
    {
        return parent::handle($request, $next);
    }*/
    public function handle($request, Closure $next)
    {
        // Add this:
        if($request->method() == 'POST')
        {
            return $next($request);
        }

        if ($request->method() == 'GET' || $this->tokensMatch($request))
        {
            return $next($request);
        }

        throw new TokenMismatchException;
    }

}

0 个答案:

没有答案