Added more descriptions of functions
This commit is contained in:
parent
dd9e9ce110
commit
3f40a6126c
@ -9,13 +9,14 @@ from werkzeug.security import generate_password_hash
|
||||
|
||||
|
||||
def admin_required(user_id, message='Access denied.'):
|
||||
"Check if common user try to make administrative action."
|
||||
user = db.session.get(User, user_id)
|
||||
if user is None or user.role != "Administrator":
|
||||
abort(403, message)
|
||||
|
||||
|
||||
def validate_access(owner_id, message='Access denied.'):
|
||||
# Check if user try to access or edit resource that does not belong to them
|
||||
"Check if user try to access or edit resource that does not belong to them."
|
||||
logged_user_id = int(get_jwt_identity())
|
||||
logged_user_role = db.session.get(User, logged_user_id).role
|
||||
if logged_user_role != "Administrator" and logged_user_id != owner_id:
|
||||
@ -31,6 +32,7 @@ def get_user_or_404(user_id):
|
||||
|
||||
|
||||
def wait_for_db(max_retries):
|
||||
"Try to connect with database <max_retries> times."
|
||||
for _ in range(max_retries):
|
||||
try:
|
||||
with db.engine.connect() as connection:
|
||||
|
Loading…
x
Reference in New Issue
Block a user