diff options
| author | Santo Cariotti <dcariotti24@gmail.com> | 2020-03-20 10:11:03 +0000 |
|---|---|---|
| committer | Santo Cariotti <dcariotti24@gmail.com> | 2020-03-20 10:11:03 +0000 |
| commit | a79bca799a5830b035df818d7e87425c25d081df (patch) | |
| tree | 2089b30b66f0022cae889cb7739860dc143d5314 /frest/decorators.py | |
| parent | 6f3c1d94a6a8858369256b63cec90d42d61706ae (diff) | |
chore: move frest dir into src
Diffstat (limited to 'frest/decorators.py')
| -rw-r--r-- | frest/decorators.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/frest/decorators.py b/frest/decorators.py deleted file mode 100644 index 181b62d..0000000 --- a/frest/decorators.py +++ /dev/null @@ -1,40 +0,0 @@ -from flask import request, abort -from auth.models import Token -from functools import wraps - - -def check_token(f): - @wraps(f) - def inner(*args, **kwargs): - userid = request.url.split('/')[-1] - headers = request.headers - if not headers.get("Authentication"): - abort(403) - - auth = request.headers.get("Authentication") - token = Token.query.filter_by(string=auth).first() - if not token: - abort(403) - - if userid.isdigit(): - if int(userid) != token.user.userId and not token.user.is_admin: - abort(403) - - return f(*args, **kwargs) - - return inner - - -def admin_required(f): - @wraps(f) - def inner(*args, **kwargs): - header = request.headers - - auth = request.headers.get("Authentication") - token = Token.query.filter_by(string=auth).first() - if not token.user.is_admin: - abort(403) - - return f(*args, **kwargs) - - return inner |
