Skip to content

Instantly share code, notes, and snippets.

@Marlysson
Last active February 14, 2022 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marlysson/767a0f769ce7b80f7f3ef7c672a4c9f5 to your computer and use it in GitHub Desktop.
Save Marlysson/767a0f769ce7b80f7f3ef7c672a4c9f5 to your computer and use it in GitHub Desktop.
Scaffold to handle policies
class MyProvider(Provider):
def __init__(self, application):
self.application = application
def register(self):
Gate.register_policies([(Project, ProjectPolicy)])
def boot(self):
pass
class ProjectController(Controller):
def show(self, view: View, auth: Auth):
auth.attempt_by_id(1) # Authentication a user to Gate handle it under the hood
permited = Gate.allows("view", Project()) # Using a mock project
return view.render("welcome", {"permitted": permitted})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment