Challenge: Access Control Decorator
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.
Løsning
Tak for dine kommentarer!
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Can you explain that in simpler terms?
What are the main benefits of this?
Are there any common issues I should watch out for?
Awesome!
Completion rate improved to 5.88
Challenge: Access Control Decorator
Stryg for at vise menuen
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.
Løsning
Tak for dine kommentarer!
single