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

Authprovider getPermissions error #4073

Closed
liviozanol opened this issue Nov 28, 2019 · 5 comments
Closed

Authprovider getPermissions error #4073

liviozanol opened this issue Nov 28, 2019 · 5 comments

Comments

@liviozanol
Copy link

What you were expecting:
AuthProvider authentication using OpenID should work correctly in react admin version 3.0.1.

What happened instead:
React-Admin returning "TypeError: Cannot read property 'then' of undefined" on ra-core/esm/auth/usePermissions.js.

Specific line: https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/auth/usePermissions.ts#L53

Steps to reproduce:
I think that if you just try to use authprovider the problem will occur. If not, let me know, so that I can provide more info/code.

Related code:
https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/auth/usePermissions.ts#L53

Other information:
React Admin is a GREAT product, thank you so much.

I'm not even near an expert on react/react-admin, so be patience.

I have read the upgrade guide, and we don't use match, context or resource. Also, we don't use AUTH_GET_PERMISSIONS (don't use permissions at all). I think the issue is related to "The authProvider No Longer Receives Default Parameters" in the upgrade, but can't confirm. 9730e6c#diff-2786406d872b3d7bd9273d26f8b1d303

If this is not a bug, forgive me.

Environment

  • React-admin version: 3.0.1
  • Last version that did not exhibit the issue (if applicable): 2.9.9
  • React version: ^16.12.0
  • Browser: chrome 78.0.3904.108
  • Stack trace (in case of a JS error):
@djhi
Copy link
Collaborator

djhi commented Nov 28, 2019

Thanks for reporting this. If you are able to illustrate the bug or feature request with an example, please provide a sample application via one of the following means:

@liviozanol
Copy link
Author

@djhi Sorry. Since I'm using a private openId provider, I can't simulate the issue on CodeSandBox or GitHub. I can however provide some parts of our RA code.

Will this help?

@fzaninotto
Copy link
Member

we don't use AUTH_GET_PERMISSIONS (don't use permissions at all)

Whether or not you use permissions, your authProvider must return a Promise for the AUTH_GET_PERMISSIONS call (can simply be Promise.resolve([])).

@liviozanol
Copy link
Author

@fzaninotto Thank you very much. It worked!

I'm so sorry that I opened this issue, but reading the message and analyzing the code and the documentation I really thought it was a bug.

Maybe it's a good idea to put in the documentation that this method MUST be defined regardles if you use it or not.

Again, I'm sorry and thank you.

@fzaninotto
Copy link
Member

The 3.0 documentation about the authProvider is quite explicit about its signature. We should probably mention the fact that AUTH_GET_PERMISSIONS is now compulsory more explicitly in the Upgrade guide. I'll open a PR for that.

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

No branches or pull requests

3 participants