Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User is not properly persisted in redux store #22

Open
dmoka opened this issue Mar 17, 2020 · 2 comments
Open

User is not properly persisted in redux store #22

dmoka opened this issue Mar 17, 2020 · 2 comments

Comments

@dmoka
Copy link

dmoka commented Mar 17, 2020

Hey!

First of all, I would like so say thank you for your project! It helped me to lot to understand the concepts and I could successfully apply it in my projects! Keep it up!

I have found out something which worries me. If I run the whole app environment (specified in the README) and if I retrieve the store somewhere, I do not see the User properly persisted in the redux store. What I have just done is to log the redux state for example at UserInfo page.

import store from '../configureStore'
import {createHashHistory} from 'history';

console.log(store(createHashHistory()).getState())

Reproduction scenario:

  1. Log in IdentityServer
  2. Open UserInfo page
  3. As a log result, I got the following:
counter: {count: 0, isLoading: false}
router: {location: {…}, action: "POP"}
oidc: {user: null, isLoadingUser: false}
__proto__: Object

As you can see the user is null. Is it the expected behaviour?

Of course, if I generally connect a component to the redux store, and I retrieve the user data via props, it can be done successfully and I can read all the relevant data (access_token, etc).
But let's say that we are at the UserInfo page showing all the data. If the access_token is refreshed (with a silentRenew) then the page is not rerendered. Is it the expected behaviour by you? I would expect a rerender, since the underlying User has got another access_token from the silentRenew.

Thank you very much for your help, I appreciate it!

Kind Regads,
Daniel Moka

@ThunderDev1
Copy link
Owner

Hi @mirind4, thanks for the feedback, I'm glad this project could help you :)

I don't quite understand the frst part of you question, if I follow your reproduction steps, the user is properly persisted to the store. You seem to be logging the store from App.tsx, this is called on intial load so the store will always be empty at that point. By the way, the store is already logged to the console with redux logger, so no need to add extra logs ;)

About the silent renew, you are right, the UserInfo page should be re-rendered, but it is not. I will have a look, and get back to you on that one.

@dmoka
Copy link
Author

dmoka commented Mar 22, 2020

Hey TunderDev1,

First of all many thanks for you answer! As for my reproduction scenario I have done it on the UserInfo page, and after I log in with an user, I checked it the logging coming from this

console.log(store(createHashHistory()).getState())

Then it produces the above mentioned result, where the user is null. If I connect to the store, I can see the user persisted, on the other hand, if I retrieve it with the command "store(createHashHistory()).getState()", I receive null for user.
But right now I think I know where the problem can come from. Does it have something to do with the fact that I create a new store with hash history in the UserInfo page? What do you think?

As for the second issue, thanks again for checking it out, I look forward to you additional feedback!
Keep it up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants