1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Http/Middleware/VerifyHash.php

33 lines
732 B
PHP
Raw Normal View History

2022-07-09 12:50:58 +02:00
<?php
namespace App\Http\Middleware;
use App\Models\PaymentHash;
use Closure;
use Illuminate\Http\Request;
class VerifyHash
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
2023-02-16 02:36:09 +01:00
if ($request->has('payment_hash')) {
2022-07-09 12:50:58 +02:00
$ph = PaymentHash::with('fee_invoice')->where('hash', $request->payment_hash)->first();
2023-02-16 02:36:09 +01:00
if ($ph) {
2022-07-09 12:50:58 +02:00
auth()->guard('contact')->loginUsingId($ph->fee_invoice->invitations->first()->contact->id, true);
2023-02-16 02:36:09 +01:00
}
2022-07-09 12:50:58 +02:00
return $next($request);
}
abort(404, 'Unable to verify payment hash');
}
}