2015-03-12 01:44:39 +01:00
|
|
|
<?php namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
|
|
|
|
|
|
|
class VerifyCsrfToken extends BaseVerifier {
|
|
|
|
|
2015-04-08 20:19:58 +02:00
|
|
|
private $openRoutes = [
|
2015-05-10 21:02:35 +02:00
|
|
|
'signup/register',
|
2015-04-08 20:19:58 +02:00
|
|
|
'api/v1/clients',
|
|
|
|
'api/v1/invoices',
|
|
|
|
'api/v1/quotes',
|
|
|
|
'api/v1/payments',
|
2015-09-07 11:07:55 +02:00
|
|
|
'api/v1/tasks',
|
2015-04-08 20:19:58 +02:00
|
|
|
'api/v1/email_invoice',
|
2015-05-10 21:02:35 +02:00
|
|
|
'api/v1/hooks',
|
2015-10-11 16:41:09 +02:00
|
|
|
'hook/email_opened',
|
|
|
|
'hook/email_bounced',
|
2015-04-08 20:19:58 +02:00
|
|
|
];
|
|
|
|
|
2015-03-12 01:44:39 +01:00
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
2015-04-08 20:19:58 +02:00
|
|
|
foreach($this->openRoutes as $route) {
|
|
|
|
|
|
|
|
if ($request->is($route)) {
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-01 23:10:20 +01:00
|
|
|
if ($request->is('login')) {
|
|
|
|
if (env(API_SECRET) && $request->api_secret === env(API_SECRET)) {
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-12 01:44:39 +01:00
|
|
|
return parent::handle($request, $next);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|