Skip to content

Commit

Permalink
fix middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
zoranbogoevski committed Nov 17, 2023
1 parent 86c3818 commit a9b6e2b
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/Middleware/CsrfExemptMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,36 @@

namespace Kalimeromk\HalkbankPayment\Middleware;

use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
use Illuminate\Http\Request;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Session\TokenMismatchException;

class CsrfExemptMiddleware extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except;

/**
* Create a new middleware instance.
*
* @return void
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
*/
public function __construct()
public function __construct(Application $app, Encrypter $encrypter)
{
$this->except = config('csrf_exempt.exempt_uris', []);
parent::__construct($app, $encrypter);

// Load your custom URIs from configuration
$this->except = config('payment.exempt_uris', []);
}

/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
* @throws TokenMismatchException
*/
public function handle($request, Closure $next)
public function handle($request, \Closure $next)
{
// Check if the request URI matches any patterns in the $except array
foreach ($this->except as $route) {
Expand Down

0 comments on commit a9b6e2b

Please sign in to comment.