Files
055-higher-lower/docs/wiki/Lecture-5-Advanced-Decorators.md
Tirsvad 1887fc347f Add lecture screenshots, README step overview and the three-language wiki
Screenshots are captured in a Docker container with a headless browser.

Task: MIL-004#1
Task: MIL-004#2
Task: MIL-004#3
Task: MIL-004#4
Task: MIL-004#5
2026-11-06 12:42:20 +08:00

15 lines
834 B
Markdown

**English** · [Dansk](Lecture-5-Advanced-Decorators-da) · [Bahasa Melayu](Lecture-5-Advanced-Decorators-ms)
# Lecture 5: Advanced decorators
![Angela is logged in and gets a post, Bob is not and gets none](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/055-higher-lower/raw/branch/main/docs/screenshots/lecture-5-authenticated.png)
Code: `src/higher_lower/presentation/lectures/step_05_authenticated.py`.
## What we gained
- `*args` collects positional arguments and `**kwargs` collects keyword arguments, so a decorator works for any function.
- `is_authenticated` reads the user from the arguments and runs the function only when `user.is_logged_in` is true.
- A decorator can control whether a function runs at all, not only change its result.
- The same pattern protects any function that needs a logged-in user.