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

Checker always returns True result #69

Closed
ishrivatsa opened this issue Apr 25, 2017 · 8 comments
Closed

Checker always returns True result #69

ishrivatsa opened this issue Apr 25, 2017 · 8 comments

Comments

@ishrivatsa
Copy link

Hi, The checkers method is returning permission result as available, when we assign a role and remove it.

@filipeximenes
Copy link
Contributor

Hi @ishrivatsa, can you provide more context? What version of the lib are you using? Can you provide a sample of the code you are seeing this behavior (please provide the role class)? Which checker method are you using?

@ishrivatsa
Copy link
Author

from rolepermissions.roles import assign_role
from django.db.auth.models import User
user = User.objects.get(id=1)
assign_role(user, 'doctor')
<class 'tml.roles.Doctor'>
from rolepermissions.checkers import has_permission
has_permission(user, 'create_medical_record')
True
has_permission(user, 'edit_patient_file')
True

The second time I run the has_permission, it should have returned false.

I am running python 3.5 in a virtual env. Django 1.10.2

Thank you.

@filipeximenes
Copy link
Contributor

Thanks! I need more information:

  • What django-role-permissions version are you using?
  • Can you paste the code for the Doctor role (or some version of it)?
  • Does this user have any other roles assigned?
  • Is this happening with fresh created users?

@ishrivatsa
Copy link
Author

Hi,

  • I am using version 2.0.1
  • Its the exact same code on the tutorial page.

from rolepermissions.roles import AbstractUserRole

class Doctor(AbstractUserRole):
available_permissions = {
'create_medical_record': True,
}

class Nurse(AbstractUserRole):
available_permissions = {
'edit_patient_file': True,
}

  • Its happening both with freshly created users and existing users.

Thank you.

@ishrivatsa
Copy link
Author

Hi @filipeximenes ,
I downloaded the source code from github and imported it into the project. That seems to be working !!

@vinyasmusic
Copy link

@ishrivatsa I am facing the same issue. How to solve this ?

@vinyasmusic
Copy link

Looked at the code, it always returns true if the user is an superuser/admin
Clarified

@filipeximenes
Copy link
Contributor

@vinyasmusic yes, that's right. It's actually a discussion we are having. Here is the link if you want to contribute: #61 (comment)

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

3 participants