1234567891011121314151617181920212223242526 |
- from flask import redirect, url_for, request
- from functools import wraps
- from .user_session import UserSession
- class Permission:
- @staticmethod
- def authorize(f):
- @wraps(f)
- def decorated_function(*args, **kwargs):
- current_user = UserSession.get_current_user()
- if not current_user.is_authenticated:
- return redirect(url_for('auth.login', next=request.url))
- return f(*args, **kwargs)
- return decorated_function
- # @staticmethod
- # def edit(f):
- # @wraps(f)
- # def decorated_function(*args, **kwargs):
- # current_user = UserSession.get_current_user()
- # if not current_user.is_authenticated:
- # return redirect(url_for('auth.login', next=request.url))
- # if not current_user.is_admin:
- # return redirect(url_for('auth.login', next=request.url))
- # return f(*args, **kwargs)
|