You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
494 B

  1. from functools import wraps
  2. from flask import abort
  3. from flask_login import current_user
  4. from .models import Permission
  5. def permission_required(permission):
  6. def decorator(f):
  7. @wraps(f)
  8. def decorated_function(*args, **kwargs):
  9. if not current_user.can(permission):
  10. abort(403)
  11. return f(*args, **kwargs)
  12. return decorated_function
  13. return decorator
  14. def admin_required(f):
  15. return permission_required(Permission.ADMIN)(f)