Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ parameters:
user_com.frontend_api_key: '%env(USER_COM_FRONTEND_API_KEY)%'
user_com.encryption_key: '%env(USER_COM_ENCRYPTION_KEY)%'
user_com.encryption_iv: '%env(USER_COM_ENCRYPTION_IV)%'

user_com.cookie_domain: '%env(USER_COM_COOKIE_DOMAIN)%'

twig:
globals:
user_com_frontend_api_key: '%user_com.frontend_api_key%'
Expand Down
1 change: 1 addition & 0 deletions config/services/manager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<argument type="service" id="request_stack"/>
<argument type="service" id="security.token_storage"/>
<argument type="service" id="bit_bag.sylius_user_com_plugin.cookie.cookie_queue"/>
<argument>%user_com.cookie_domain%</argument>
</service>

<service
Expand Down
5 changes: 5 additions & 0 deletions src/Manager/CookieManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct(
private readonly RequestStack $requestStack,
private readonly TokenStorageInterface $tokenStorage,
private readonly CookieQueueInterface $queue,
private readonly ?string $cookieDomain = null,
) {
}

Expand Down Expand Up @@ -51,6 +52,10 @@ public function setUserComCookie(string $value): void
->withHttpOnly(true)
->withSameSite('lax');

if (null !== $this->cookieDomain && '' !== $this->cookieDomain) {
$cookie = $cookie->withDomain($this->cookieDomain);
}

$this->queue->queue($cookie);
}

Expand Down
1 change: 1 addition & 0 deletions tests/Application/.env
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN=doctrine://defau
USER_COM_FRONTEND_API_KEY=""
USER_COM_ENCRYPTION_KEY=your-32-character-long-key
USER_COM_ENCRYPTION_IV=your-16-character-long-
USER_COM_COOKIE_DOMAIN=""
MESSENGER_USER_COM_ASYNCHRONOUS_DSN="doctrine://default"
###< UserCom