Skip to content

Commit

Permalink
Ensure cookieDomain is used when using legacy Cookiestorage (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck authored Feb 4, 2023
1 parent 539c8e4 commit cf01c72
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions __tests__/Auth0Client/loginWithPopup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@ describe('Auth0Client', () => {
`_legacy_auth0.${TEST_CLIENT_ID}.organization_hint`,
JSON.stringify(TEST_ORG_ID),
{
expires: 1
expires: 1,
domain: TEST_DOMAIN
}
);

Expand All @@ -702,11 +703,13 @@ describe('Auth0Client', () => {
await loginWithPopup(auth0);

expect(<jest.Mock>esCookie.remove).toHaveBeenCalledWith(
`_legacy_auth0.${TEST_CLIENT_ID}.organization_hint`, {}
`_legacy_auth0.${TEST_CLIENT_ID}.organization_hint`,
{}
);

expect(<jest.Mock>esCookie.remove).toHaveBeenCalledWith(
`auth0.${TEST_CLIENT_ID}.organization_hint`, {}
`auth0.${TEST_CLIENT_ID}.organization_hint`,
{}
);
});

Expand Down
3 changes: 2 additions & 1 deletion __tests__/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ describe('CookieStorageWithLegacySameSite', () => {
`_legacy_${key}`,
JSON.stringify(value),
{
expires: options.daysUntilExpire
expires: options.daysUntilExpire,
domain: options.cookieDomain
}
);
});
Expand Down
4 changes: 4 additions & 0 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export const CookieStorageWithLegacySameSite = {
cookieAttributes.expires = options.daysUntilExpire;
}

if (options?.cookieDomain) {
cookieAttributes.domain = options.cookieDomain;
}

Cookies.set(
`${LEGACY_PREFIX}${key}`,
JSON.stringify(value),
Expand Down

0 comments on commit cf01c72

Please sign in to comment.