Last active
February 14, 2022 00:54
-
-
Save Marlysson/767a0f769ce7b80f7f3ef7c672a4c9f5 to your computer and use it in GitHub Desktop.
Scaffold to handle policies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyProvider(Provider): | |
def __init__(self, application): | |
self.application = application | |
def register(self): | |
Gate.register_policies([(Project, ProjectPolicy)]) | |
def boot(self): | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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