mirror of
https://github.com/Xevion/v1.xevion.dev.git
synced 2025-12-06 15:16:59 -06:00
form progress
This commit is contained in:
14
app/custom.py
Normal file
14
app/custom.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from flask import abort
|
||||
from flask_login import current_user
|
||||
from functools import wraps
|
||||
|
||||
def require_role(roles=["User"]):
|
||||
def wrap(func):
|
||||
@wraps(func)
|
||||
def decorated_view(*args, **kwargs):
|
||||
if current_user.is_authenticated:
|
||||
if current_user.has_roles(roles):
|
||||
return func(*args, **kwargs)
|
||||
return abort(401)
|
||||
return decorated_view
|
||||
return wrap
|
||||
Reference in New Issue
Block a user