-
-
Notifications
You must be signed in to change notification settings - Fork 642
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
Fetch user before pass it to the restricted function #6293
Conversation
✅ Deploy Preview for plone-components canceled.
|
5dd6e3d
to
55f1c7c
Compare
It may not be in the Redux store yet when we try to pass it in. So we dispatch if it's not in the store.
93e876a
to
bd5c4cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I am not sure I understand what problem we are trying to solve here. Aren't the components getting an update (rerender triggered by useSelector) when the user is finally fetched, even if it's not there when these components are first rendered? In other words, does it break somehow, or what is the issue here? |
@pnicolli Consider the case where the user is logged out, then they log in and edit the page. Then we have to dispatch getUser, because the user isn't in the store yet. In this scenario there is no SSR request at a point in time when the user is logged in. |
I thought the user should get into the store eventually when the user logs into the portal, but I trust you to have done more research than I did on the subject 😁 👍 |
@pnicolli not the case, but it's a good point. @davisagli thoughts? |
Well I was thinking... maybe we should consider for Volto 19 to move the user info to an expander we get with the content? Would it be worth it? I don't want to clutter anybody's notifications though, so maybe I could give this a little more thought and discuss it at a Volto Team meeting |
I also had the idea of fetching the user info when the user logs in, but it doesn't avoid the need for what we have in this PR, because sometimes the user loads the page from the server while already logged in. I don't think user info belongs in an expander because it's information that does not depend on which content item is being fetched. It would also make it hard to cache content responses in a way that is shared between multiple users with the same roles. |
It may not be in the Redux store yet when we try to pass it in. So we dispatch if it's not in the store.