mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-27 16:34:13 +00:00
Implement authorization checking for external api user using api key
This commit is contained in:
@@ -5,6 +5,8 @@ namespace App\Classes\Modules\WePost\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\WePost\Services\CreatesWePostNotification;
|
||||
use App\Classes\Modules\WePost\DataTransferObjects\WePostNotificationObject;
|
||||
use App\Classes\Modules\WePost\DataTransferObjects\WePostProcessNotificationObject;
|
||||
use App\Classes\Modules\WePost\Standards\Rules\CanProcessWePostNotification;
|
||||
use App\Http\Resources\WePostNotificationResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -24,14 +26,19 @@ class ProcessWePostNotificationLogic extends AbstractControllerLogic
|
||||
/** @var CreatesWePostNotification */
|
||||
private $createsWePostNotification;
|
||||
|
||||
/** @var CanProcessWePostNotification */
|
||||
private $canProcessWePostNotification;
|
||||
|
||||
/**
|
||||
* ProcessWePostNotificationLogic constructor.
|
||||
* @param CreatesWePostNotification $createsWePostNotification
|
||||
* @param CanProcessWePostNotification $canProcessWePostNotification
|
||||
*/
|
||||
public function __construct(
|
||||
CreatesWePostNotification $createsWePostNotification)
|
||||
CreatesWePostNotification $createsWePostNotification, CanProcessWePostNotification $canProcessWePostNotification)
|
||||
{
|
||||
$this->createsWePostNotification = $createsWePostNotification;
|
||||
$this->canProcessWePostNotification = $canProcessWePostNotification;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +50,9 @@ class ProcessWePostNotificationLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new WePostProcessNotificationObject($request->query('api-key'));
|
||||
$this->canProcessWePostNotification->passes($object);
|
||||
|
||||
$request->merge([
|
||||
'isApiPub' => true,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user