本文整理汇总了PHP中Illuminate\Foundation\Http\Middleware\VerifyCsrfToken类的典型用法代码示例。如果您正苦于以下问题:PHP VerifyCsrfToken类的具体用法?PHP VerifyCsrfToken怎么用?PHP VerifyCsrfToken使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VerifyCsrfToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
public function handle($request, \Closure $next)
{
try {
return parent::handle($request, $next);
} catch (TokenMismatchException $e) {
return $this->unauthorizedResponse();
}
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!\Request::is('ws/*') && !\Request::ajax()) {
return parent::handle($request, $next);
}
return $this->addCookieToResponse($request, $next($request));
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ('testing' !== app()->environment()) {
return parent::handle($request, $next);
}
return $next($request);
}
示例4: handle
/**
* {@inheritDoc}
*/
public function handle($request, Closure $next)
{
if (is_api_request()) {
return $this->addCookieToResponse($request, $next($request));
}
return parent::handle($request, $next);
}
示例5: tokensMatch
protected function tokensMatch($request)
{
if ($request->wantsJson()) {
return true;
}
return parent::tokensMatch($request);
}
示例6: handle
public function handle($request, Closure $next)
{
if (!$request->is("api/*")) {
return parent::handle($request, $next);
}
return $next($request);
}
示例7: addCookieToResponse
/**
* Add the CSRF token to the response cookies.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Response $response
* @return \Illuminate\Http\Response
*/
protected function addCookieToResponse($request, $response)
{
if ('array' !== config('session.driver')) {
return parent::addCookieToResponse($request, $response);
}
return $response;
}
示例8: shouldPassThrough
protected function shouldPassThrough($request)
{
if ($request->is('login') && $request->ajax()) {
return true;
}
return parent::shouldPassThrough($request);
}
示例9: handle
/**
* {@inheritDoc}
*/
public function handle($request, Closure $next)
{
if (is_api_request()) {
return $next($request);
}
return parent::handle($request, $next);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->shouldIgnore($request)) {
return $this->addCookieToResponse($request, $next($request));
}
return parent::handle($request, $next);
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->getRequestUri() == '/en/update/docs') {
return $next($request);
}
return parent::handle($request, $next);
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->method() == 'POST') {
return $next($request);
}
return parent::handle($request, $next);
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\App::environment() == 'testing') {
return $next($request);
}
return parent::handle($request, $next);
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$userKey = $request->input('_key');
if ($userKey && !empty($userKey)) {
$user = User::where('user_key', $userKey)->first();
if (Auth::check()) {
$prevuser = Auth::user();
Auth::logout();
}
if ($user->exists()) {
Auth::login($user);
$response = $next($request);
Auth::logout();
if (isset($prevuser) && isset($prevuser->id)) {
Auth::login($prevuser);
}
return $response;
} else {
$response = $next($request);
}
if (isset($prevuser)) {
Auth::login($prevuser);
}
return $response;
}
if ($request->is('api/v1/donate/ipn')) {
return $next($request);
}
return parent::handle($request, $next);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (strpos($request, 'infusion')) {
return $this->addCookieToResponse($request, $next($request));
}
return parent::handle($request, $next);
}