Skip to content

Commit 9ea4488

Browse files
authored
Merge pull request #43 from BitBagCommerce/UC-30-fix-cookie
[UC-30] Introduce cookie queue handling and implement CookieFlusherSu…
2 parents 2540e30 + f42018e commit 9ea4488

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

config/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ parameters:
22
user_com.frontend_api_key: '%env(USER_COM_FRONTEND_API_KEY)%'
33
user_com.encryption_key: '%env(USER_COM_ENCRYPTION_KEY)%'
44
user_com.encryption_iv: '%env(USER_COM_ENCRYPTION_IV)%'
5-
5+
user_com.cookie_domain: '%env(USER_COM_COOKIE_DOMAIN)%'
6+
67
twig:
78
globals:
89
user_com_frontend_api_key: '%user_com.frontend_api_key%'

config/services/manager.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<argument type="service" id="request_stack"/>
1111
<argument type="service" id="security.token_storage"/>
1212
<argument type="service" id="bit_bag.sylius_user_com_plugin.cookie.cookie_queue"/>
13+
<argument>%user_com.cookie_domain%</argument>
1314
</service>
1415

1516
<service

src/Manager/CookieManager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function __construct(
2323
private readonly RequestStack $requestStack,
2424
private readonly TokenStorageInterface $tokenStorage,
2525
private readonly CookieQueueInterface $queue,
26+
private readonly ?string $cookieDomain = null,
2627
) {
2728
}
2829

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

55+
if (null !== $this->cookieDomain && '' !== $this->cookieDomain) {
56+
$cookie = $cookie->withDomain($this->cookieDomain);
57+
}
58+
5459
$this->queue->queue($cookie);
5560
}
5661

tests/Application/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN=doctrine://defau
3636
USER_COM_FRONTEND_API_KEY=""
3737
USER_COM_ENCRYPTION_KEY=your-32-character-long-key
3838
USER_COM_ENCRYPTION_IV=your-16-character-long-
39+
USER_COM_COOKIE_DOMAIN=""
3940
MESSENGER_USER_COM_ASYNCHRONOUS_DSN="doctrine://default"
4041
###< UserCom

0 commit comments

Comments
 (0)