This commit is contained in:
Mateusz Gruszczyński
2026-03-13 11:03:13 +01:00
commit 35571df778
132 changed files with 11197 additions and 0 deletions

16
app/utils/decorators.py Normal file
View File

@@ -0,0 +1,16 @@
from functools import wraps
from flask import abort
from flask_login import current_user
def roles_required(*roles):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
if not current_user.is_authenticated:
abort(401)
if current_user.role not in roles:
abort(403)
return func(*args, **kwargs)
return wrapper
return decorator