Fix multiple Needs on OctoPrintPermission

fixes #3398
This commit is contained in:
fieldOfView committed 2020-01-03 08:41:59 -08:00
1 parent 74f3bc9ae6
commit 7191d39b51
1 file changed
+16
+16
View File
@@ -79,6 +79,22 @@ class OctoPrintPermission(Permission):
def get_description(self):
return self._description
def allows(self, identity):
"""Whether the identity can access this permission.
Overridden from Permission.allows to make sure the Identity provides ALL
required needs instead of ANY required need.
:param identity: The identity
"""
if self.needs and len(self.needs.intersection(identity.provides)) != len(self.needs):
return False
if self.excludes and self.excludes.intersection(identity.provides):
return False
return True
def union(self, other):
"""Create a new OctoPrintPermission with the requirements of the union of this
and other.