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
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
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
Sveip for å vise menyen
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
Takk for tilbakemeldingene dine!
single