caxap / rest_condition

Complex permissions flow for django-rest-framework (http://django-rest-framework.org).
MIT License
281 stars 29 forks source link

Permission check return values should be explicitly casted to bool #7

Closed eisensheng closed 8 years ago

eisensheng commented 8 years ago

Permission tests like rest_framework.permissions.IsAdminUser may return None. This isn't covered well in rest_condition.permissions.Condition and thus the permission check leaves early with an unexpected exception.

  File "…/lib/python3.5/site-packages/rest_condition/permissions.py", line 113, in has_permission
    return self.evaluate_permissions('has_permission', request, view)
  File "…/lib/python3.5/site-packages/rest_condition/permissions.py", line 98, in evaluate_permissions
    reduced_result = self.reduce_op(reduced_result, result)
TypeError: unsupported operand type(s) for |: 'NoneType' and 'bool'
caxap commented 8 years ago

Fixed in v1.0.3 https://github.com/caxap/rest_condition/commit/ce2ced84f67dbb9b371a36311006723a749e1e8f