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

has_role_decorator catch exception #109

Open
MiltosD opened this issue Jan 23, 2020 · 2 comments
Open

has_role_decorator catch exception #109

MiltosD opened this issue Jan 23, 2020 · 2 comments

Comments

@MiltosD
Copy link

MiltosD commented Jan 23, 2020

I am trying to use this package with rest framework. However, the "has_role_decorator" function raises an exception when the user does not have the role, as expected. Is it possible to catch this exception in my ViewSet in order to return a "Permission Denied" REST response?

@MiltosD
Copy link
Author

MiltosD commented Jan 23, 2020

I suppose overriding HasRoleMixin.dispatch could work, however, I cannot seem to handle read_only if has_role_decorator fails

@filipeximenes
Copy link
Contributor

Hi @MiltosD, what do you mean by read_only? Could you check for the request method before suppressing the exception or not?

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