|
@@ -7,7 +7,6 @@ use ApiPlatform\State\ProcessorInterface;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
use Webkul\BagistoApi\Dto\SubscribeToNewsletterInput;
|
|
use Webkul\BagistoApi\Dto\SubscribeToNewsletterInput;
|
|
|
-use Webkul\BagistoApi\Exception\AuthorizationException;
|
|
|
|
|
use Webkul\BagistoApi\Exception\InvalidInputException;
|
|
use Webkul\BagistoApi\Exception\InvalidInputException;
|
|
|
use Webkul\Core\Models\SubscribersListProxy;
|
|
use Webkul\Core\Models\SubscribersListProxy;
|
|
|
|
|
|
|
@@ -44,22 +43,12 @@ class NewsletterSubscriptionProcessor implements ProcessorInterface
|
|
|
try {
|
|
try {
|
|
|
$customer = Auth::guard('sanctum')->user();
|
|
$customer = Auth::guard('sanctum')->user();
|
|
|
|
|
|
|
|
- if (! $customer) {
|
|
|
|
|
- throw new AuthorizationException(__('bagistoapi::app.graphql.logout.unauthenticated'));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $token = $customer->currentAccessToken();
|
|
|
|
|
-
|
|
|
|
|
- if (! $token) {
|
|
|
|
|
- throw new AuthorizationException(__('bagistoapi::app.graphql.logout.token-not-found-or-expired'));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
SubscribersListProxy::create([
|
|
SubscribersListProxy::create([
|
|
|
'email' => $data->customerEmail,
|
|
'email' => $data->customerEmail,
|
|
|
'channel_id' => $data?->channelId ?? core()->getCurrentChannel()->id,
|
|
'channel_id' => $data?->channelId ?? core()->getCurrentChannel()->id,
|
|
|
'is_subscribed' => 1,
|
|
'is_subscribed' => 1,
|
|
|
'token' => uniqid(),
|
|
'token' => uniqid(),
|
|
|
- 'customer_id' => $customer ? $customer?->id : null,
|
|
|
|
|
|
|
+ 'customer_id' => $customer?->id,
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
return (object) [
|
|
return (object) [
|