P粉6589549142023-08-26 11:07:29
Per @Estus Flask's comment, I used a custom storage and managed the "remember me" option by calling localStorage directly and setting a flag in localStorage.
plugins: [ createPersistedState({ paths: ["authentication.userAuthenticationInfo"], storage: { getItem(key) { if (localStorage.getItem("rememberMe") == 1) { return localStorage.getItem(key); } else { return Cookies.get(key); //return sessionStorage.getItem(key); } }, setItem(key, value) { if (localStorage.getItem("rememberMe") == 1) { localStorage.setItem(key, value); } else { Cookies.set(key, value); //sessionStorage.setItem(key, value); } }, removeItem(key) { if (localStorage.getItem("rememberMe") == 1) { localStorage.removeItem(key); } else { Cookies.remove(key); //sessionStorage.removeItem(key); } }, }, }), ],
And I clear localStorage on every logout or 401 response.