Files
exchange-2.0/app/Classes/Modules/Segments/Processors/RiskAnalysisProcessor.php
T
2022-08-16 14:49:56 +08:00

37 lines
1.0 KiB
PHP

<?php
namespace App\Classes\Modules\Segments\Processors;
use App\Classes\Modules\Companies\Processors\AssignSegmentProcessor;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use TimeHunter\LaravelGoogleReCaptchaV3\Core\GoogleReCaptchaV3Response;
use TimeHunter\LaravelGoogleReCaptchaV3\Facades\GoogleReCaptchaV3;
class RiskAnalysisProcessor
{
/** @var AssignSegmentProcessor */
private $assignSegmentProcessor;
/**
* RiskAnalysisProcessor constructor.
* @param AssignSegmentProcessor $assignSegmentProcessor
*/
public function __construct(AssignSegmentProcessor $assignSegmentProcessor)
{
$this->assignSegmentProcessor = $assignSegmentProcessor;
}
function execute(User $user, string $token){
$captchaToken = GoogleReCaptchaV3::verifyResponse($token);
if($captchaToken->getScore() < 0.6 && !in_array('timeout-or-duplicate', $captchaToken->getErrorCodes())){
$this->assignSegmentProcessor->execute($user->company()->first(), 18);
}
}
}