perm = Perm()
perm.app = app
perm.init_app(app)
print perm.has_permission(user_id, 'product.add') # True
print perm.get_user_permissions(user_id) # ['product.add', 'product.update']
@perm.require_permission('product.delete') # throw perm.Denied
def add_or_update_product(product_id):
# do something
@app.errorhandler(perm.Denied)
def handle_perm_denied(e):
return jsonify({msg: 'permission denied'}), 403
-
Notifications
You must be signed in to change notification settings - Fork 0
xiewenlongs/flask_perm_2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published