-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
4.0.2 > 4.1.0 breaking changes #7725
Comments
Hi, and thanks for your feedback. This is likely linked to changes introduced in 4.0.3 (#7606, #7609). Regarding your second point, I can't reproduce it in the simple example codesandbox, which uses a function that does not return a Promise. https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple Could you please build a repro based on that CodeSandbox? Regarding your first point, I'm not sure this is a bug - we'll also need a repro to see. Thanks in advance |
@fzaninotto I can't (unfortunately no time). But:
this is in useConfigureAdminRouterFromChildren.tsx I don't know why the sandbox doesn't have the issue. Feel free to close this if this isn't enough info, no hard feelings 😄 Update: actually, this shows the issue. It's checking for .then on |
That's the problem: the function shouldn't return null, but a list of children. I believe this is due to the fact that, if you don't have permissions, you return nothing. I managed to reproduce the second error : https://codesandbox.io/s/wonderful-lichterman-lez2zo?file=/src/authProvider.tsx So I'm marking this as a bug - But I'm not sure what the admin should show when the function returns nothing. |
@fzaninotto The first call to the permissions function (with undefined) used to not happen, I think that's why I noticed the null issue now. If you don't have permissions you're not allowed to see any of the resources. When you log in, I can finally start filtering resources. But returning null from a promise is allowed and doesn't break, so it's not fatal. Just interesting 😄 |
Hm, something does seem broken. It's no longer redirecting me to /login when I'm not logged in, for some reason. I'll reply here once I find out what the problem is. |
I'm not able to figure out what's going on. It's calling the permission method twice and if neither returns anything it's not sending me to login. It's hard to share the code but I "fixed" (hack) it like so: <Admin>
{async p => {
try {
await Auth.currentSession();
} catch (error) {
if (!window.location.hash.startsWith('#/accept-invite?')) window.top.location = '/#/login'
}
if (!p) return null;
}}
</Admin> If not authenticated, and url is not something that is allowed send to login. If !p (permissions) return null and wait until they do exist. I think I can share the project with you directly, I'm just not allowed to just upload it to github because of contracts. |
What you were expecting:
I just updated to 4.1.0 and notice some breaking changes.
Both of these weren't an issue on 4.0.2.
I fixed these issues easily by adding a simple
if (!p) return null
at the top of the function and making it async. Visually:The reason I am still writing this issue is because this version is tagged as a minor version and so it should have been backwards compatible. I thought you might want to know.
Update: I just tested the rest and all my other issues were fixed in this release though, so I am actually really happy with 4.1.0
The text was updated successfully, but these errors were encountered: