No Description
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.

acl.py 664B

1234567891011121314151617181920
  1. #-*- conding: utf-8 -*-
  2. from Lodel.hooks import LodelHook
  3. from Lodel.user import UserContext
  4. class PermissionDenied(Exception): pass
  5. @LodelHook('leapi_get_pre', 1)
  6. def check_anon(hook_name, caller, payload):
  7. if not UserContext.identity().is_identified:
  8. raise PermissionDenied("Anonymous user's are not allowed to get content")
  9. return payload
  10. @LodelHook('leapi_update_pre', 1)
  11. @LodelHook('leapi_delete_pre', 1)
  12. @LodelHook('leapi_insert_pre', 1)
  13. def check_auth(hook_name, caller, payload):
  14. if not UserContext.identity().is_authenticated:
  15. raise PermissionDenied("Only authenticated user's are allowed to do that !")
  16. return payload