You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Hybrid] PWA Kit should have a mechanism for replacing the access token when a SFRA login state is changed (#1171)
* Implement mechanism to store refresh token copy and compare with sfra
* Update tests and mocks for util function to check SFRA login state
* Fix linting issues
* FIx param types for util functionn
* Rename old isTokenValid to isTokenExpired
* Remove expiry for refresh_token in localstorage
* Update packages/template-retail-react-app/app/commerce-api/utils.js
Co-authored-by: Kevin He <kevin.he@salesforce.com>
* fix test
* Fix linting on use-auth-modal.test.js
* Update hasSFRAStateChanged logic to compare keys and values
* Fix linting
---------
Co-authored-by: Kevin He <kevin.he@salesforce.com>
* WARNING: This function is relevant to be used in Hybrid deployments only.
278
+
* Compares the refresh_token keys for guest('cc-nx-g') and registered('cc-nx') login from the cookie received from SFRA with the copy stored in localstorage on PWA Kit
279
+
* to determine if the login state of the shopper on SFRA site has changed. If the keys are different we return true considering the login state did change. If the keys are same,
280
+
* we compare the values of the refresh_token to cover an edge case where the login state might have changed multiple times on SFRA and the eventual refresh_token key might be same
281
+
* as that on PWA Kit which would incorrectly show both keys to be the same even though the sessions are different.
282
+
* @param {Storage} storage Cookie storage on PWA Kit in hybrid deployment.
283
+
* @param {LocalStorage} storageCopy Local storage holding the copy of the refresh_token in hybrid deployment.
284
+
* @returns {boolean} true if the keys do not match (login state changed), false otherwise.
0 commit comments