feat: Semaine 9

This commit is contained in:
gauvainboiche
2026-05-15 16:24:56 +02:00
parent 3315cb2336
commit ce1f0e513a
108 changed files with 3150 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
from dataclasses import dataclass
from typing import Callable
@dataclass
class User:
username: str
is_authenticated: bool = False
def authentication_required(fonction: Callable):
def internal_wrapper(user: User):
if not user.is_authenticated:
return PermissionError(f"L'utilisateur {user.username} n'est pas authentifié.")
return fonction(user)
return internal_wrapper
@authentication_required
def operation_sensible(user: User):
return f"Opération sensible faite par {user.username}."
alice = User("alice@courriel.fr", True)
bob = User("bob@courriel.fr")
print(operation_sensible(alice))
print(operation_sensible(bob))