Commits

Ali Afshar  committed 2de14ed

Added a shortcut so permissions can check identity permission

  • Participants
  • Parent commits 757ccbf

Comments (0)

Files changed (1)

File flaskext/principal.py

 
         :param permission: The permission to test provision for.
         """
-        if not permission.needs:
-            return True
-        else:
-            return permission.needs.intersection(self.provides)
+        return permission.allows(self)
 
 
 class AnonymousIdentity(Identity):
 
         :param identity: The identity
         """
-        return identity.can(self)
+        if not self.needs:
+            return True
+        else:
+            return self.needs.intersection(identity.provides)
+
+    def can(self):
+        """Whether the required context for this permission has access
+
+        This creates an identity context and tests whether it can access this
+        permission
+        """
+        return self.require().can()
 
 
 def session_identity_loader():