maxmantz/redux-oidc

user State is not getting maintained between browser tabs

Jaganprafful opened this issue · 2 comments

Using the example I have configured my userManger, store, and HomePage but the issue with private routing I have enabled it by adding an additional reducer. If the user is logged in one tab when trying to invoke another tab directly bypassing the URL path application is redirecting back to the login page instead it should go the specified path and also in the session storage user object is not getting persisted so I am unable to secure my app

Here is my store file
image

And added an additional reducer for managing the authenticated state

image

Here is my privaterouter.tsx which allows only authenticated users

image

@maxmantz Can you please help me out as the user state in the new tab is not loaded even the user is logged in another tab, couldn't figure out whats the root cause

oidc-client-js stores session information in session storage by default, not local storage. Session storage is per tab. This is an except from the oidc-client-js config documentation on how to use local storage.

userStore: (default: session storage): Storage object used to persist User for currently authenticated user. 
E.g. userStore: new WebStorageStateStore({ store: window.localStorage })

Thank you, now I am using localStorage for maintaining the user store that resolved my issue.