35 lines
1.4 KiB
PHP
35 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Models\InvestmentSubmission;
|
|
use Closure;
|
|
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
/** Tempo 19/10/2026: exception for simple participation only; formal operations retain verification. */
|
|
class VerifiedOrSimpleParticipation
|
|
{
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
if ($request->user()->hasVerifiedEmail()) {
|
|
return $next($request);
|
|
}
|
|
if ($request->isMethod('GET') && $request->is('investidor/manifestacoes', 'api/v1/investment/submissions')) {
|
|
return $next($request);
|
|
}
|
|
$id = $request->route('id');
|
|
$show = $request->isMethod('GET') && $request->is('investidor/manifestacoes/'.$id, 'api/v1/investment/submissions/'.$id);
|
|
$message = $request->isMethod('POST') && $request->is('investidor/manifestacoes/'.$id.'/messages', 'api/v1/investment/submissions/'.$id.'/messages');
|
|
if ($id && ($show || $message)) {
|
|
$row = InvestmentSubmission::whereKey($id)->where('user_id', $request->user()->id)->firstOrFail();
|
|
if ($row->status === 'submitted' && ($row->payload['simple_participation'] ?? false) === true) {
|
|
return $next($request);
|
|
}
|
|
}
|
|
|
|
return app(EnsureEmailIsVerified::class)->handle($request, $next);
|
|
}
|
|
}
|