mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
20 lines
494 B
Python
20 lines
494 B
Python
|
from functools import wraps
|
||
|
from flask import abort
|
||
|
from flask_login import current_user
|
||
|
from .models import Permission
|
||
|
|
||
|
|
||
|
def permission_required(permission):
|
||
|
def decorator(f):
|
||
|
@wraps(f)
|
||
|
def decorated_function(*args, **kwargs):
|
||
|
if not current_user.can(permission):
|
||
|
abort(403)
|
||
|
return f(*args, **kwargs)
|
||
|
return decorated_function
|
||
|
return decorator
|
||
|
|
||
|
|
||
|
def admin_required(f):
|
||
|
return permission_required(Permission.ADMIN)(f)
|