@eeacms/volto-eea-website-theme 3.11.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/package.json +1 -1
- package/razzle.extend.js +24 -0
- package/src/middleware/conditionalLocalStorage.js +56 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [3.12.0](https://github.com/eea/volto-eea-website-theme/compare/3.11.0...3.12.0) - 4 November 2025
|
|
8
|
+
|
|
9
|
+
#### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
- fix: Don't save localstorage entries for anonymous users - refs #289423 [Teodor Voicu - [`0ed847a`](https://github.com/eea/volto-eea-website-theme/commit/0ed847af98fe0fcecb1d632e5136b9987eef437b)]
|
|
12
|
+
|
|
13
|
+
#### :hammer_and_wrench: Others
|
|
14
|
+
|
|
15
|
+
- Release 3.12.0 [Alin Voinea - [`ea1e961`](https://github.com/eea/volto-eea-website-theme/commit/ea1e96144684b2a8238ae476fd8d47de82ff42b4)]
|
|
7
16
|
### [3.11.0](https://github.com/eea/volto-eea-website-theme/compare/3.10.1...3.11.0) - 29 September 2025
|
|
8
17
|
|
|
9
18
|
#### :bug: Bug Fixes
|
package/package.json
CHANGED
package/razzle.extend.js
CHANGED
|
@@ -25,6 +25,30 @@ const modify = (config, { target, dev }, webpack) => {
|
|
|
25
25
|
? themeLessPath
|
|
26
26
|
: semanticLessPath;
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* TODO: Remove these aliases after https://github.com/plone/volto/issues/6997 is resolved
|
|
30
|
+
*
|
|
31
|
+
* This workaround prevents localStorage pollution for anonymous users by intercepting
|
|
32
|
+
* redux-localstorage-simple with our conditional middleware wrapper.
|
|
33
|
+
*
|
|
34
|
+
* Once the issue is fixed in Volto core:
|
|
35
|
+
* 1. Remove the alias configurations below
|
|
36
|
+
* 2. Remove the conditionalLocalStorage.js middleware file
|
|
37
|
+
*/
|
|
38
|
+
// Alias redux-localstorage-simple to conditional middleware
|
|
39
|
+
const conditionalLocalStoragePath = path.resolve(
|
|
40
|
+
__dirname,
|
|
41
|
+
'./src/middleware/conditionalLocalStorage',
|
|
42
|
+
);
|
|
43
|
+
alias['redux-localstorage-simple'] = conditionalLocalStoragePath;
|
|
44
|
+
|
|
45
|
+
// Create an alias to access the original redux-localstorage-simple package
|
|
46
|
+
const originalReduxLocalStoragePath = path.resolve(
|
|
47
|
+
__dirname,
|
|
48
|
+
'../../../node_modules/redux-localstorage-simple',
|
|
49
|
+
);
|
|
50
|
+
alias['redux-localstorage-simple-original'] = originalReduxLocalStoragePath;
|
|
51
|
+
|
|
28
52
|
return config;
|
|
29
53
|
};
|
|
30
54
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TODO: Remove this workaround after https://github.com/plone/volto/issues/6997 is resolved
|
|
5
|
+
*
|
|
6
|
+
* This file provides a conditional wrapper for redux-localstorage-simple to prevent
|
|
7
|
+
* localStorage pollution for anonymous users. The import uses 'redux-localstorage-simple-original'
|
|
8
|
+
* as an alias to the actual package to avoid circular dependencies.
|
|
9
|
+
*
|
|
10
|
+
* Once the issue is fixed in Volto core:
|
|
11
|
+
* 1. Remove this conditionalLocalStorage.js file
|
|
12
|
+
* 2. Remove the webpack alias configuration for 'redux-localstorage-simple-original'
|
|
13
|
+
*/
|
|
14
|
+
import {
|
|
15
|
+
save as reduxLocalStorageSave,
|
|
16
|
+
load as reduxLocalStorageLoad,
|
|
17
|
+
} from 'redux-localstorage-simple-original';
|
|
18
|
+
|
|
19
|
+
const isUserAuthenticated = (state) => {
|
|
20
|
+
return !!(
|
|
21
|
+
state?.userSession?.token ||
|
|
22
|
+
state?.users?.user?.token ||
|
|
23
|
+
state?.users?.user?.id ||
|
|
24
|
+
state?.userSession?.user?.id
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const isAuthAction = (action) => {
|
|
29
|
+
return action.type && action.type.includes('LOGIN');
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Wrapper for redux-localstorage-simple's save middleware
|
|
34
|
+
* Only allows saving to localStorage when user is authenticated or an authentication action is happening
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
export const save = (options = {}) => {
|
|
38
|
+
const saveMiddleware = reduxLocalStorageSave(options);
|
|
39
|
+
|
|
40
|
+
return (store) => {
|
|
41
|
+
const wrappedSaveMiddleware = saveMiddleware(store);
|
|
42
|
+
|
|
43
|
+
return (next) => (action) => {
|
|
44
|
+
const state = store.getState();
|
|
45
|
+
const shouldSave = isUserAuthenticated(state) || isAuthAction(action);
|
|
46
|
+
|
|
47
|
+
if (shouldSave) {
|
|
48
|
+
return wrappedSaveMiddleware(next)(action);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return next(action);
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export { reduxLocalStorageLoad as load };
|