Section 4. Chapter 3
single
Challenge: Access Control Decorator
Swipe to show menu
Task
Swipe to start coding
Write a decorator called require_admin that restricts access to the decorated function. The function should only run if the global variable IS_ADMIN is True. If IS_ADMIN is not True, the decorator must raise a PermissionError. The decorator must work for any function it decorates.
Solution
Everything was clear?
Thanks for your feedback!
Section 4. Chapter 3
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat