__init__.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from flask import Blueprint, flash, redirect, url_for, request
  2. bp = Blueprint('auth', __name__)
  3. from app.auth import routes
  4. from flask_login import current_user
  5. from functools import wraps
  6. def check_admin(f):
  7. @wraps(f)
  8. def decorated_function(*args, **kwargs):
  9. if current_user.bl_admin!=True:
  10. flash("you must be logged in as an administrative user")
  11. return redirect(url_for('auth.login', next=request.url))
  12. else:
  13. return f(*args, **kwargs)
  14. # end of checking if super user
  15. # end of decorated function
  16. return decorated_function
  17. # end of check_admin decorator
  18. def check_capture(f):
  19. @wraps(f)
  20. def decorated_function(*args, **kwargs):
  21. if current_user.bl_admin!=True and current_user.bl_capture!=True:
  22. flash("you must be logged in as an administrative or capturing user")
  23. return redirect(url_for('auth.login', next=request.url))
  24. else:
  25. return f(*args, **kwargs)
  26. # end of checking if super or at least capturing user
  27. # end of decorated function
  28. return decorated_function
  29. # end of check_capture decorator