summaryrefslogtreecommitdiff
path: root/sw/auth.py
diff options
context:
space:
mode:
authorTom Harley2021-07-09 15:16:54 +0000
committerTom Harley2021-07-09 15:16:54 +0000
commit57e7488149ee093e34774d83ffe161fb305a7dde (patch)
treeed922a052cd8eb6fc5b77c21970cb0d0b02b9cb3 /sw/auth.py
parentAdd testing for authorisation decorators (diff)
downloadswap-57e7488149ee093e34774d83ffe161fb305a7dde.tar.gz
swap-57e7488149ee093e34774d83ffe161fb305a7dde.zip

Add basic inbox/outbox functionality

Lots of added TODOs, and very little test coverage for the new functions.

Next step is to get 100% coverage of what we have so far.

Diffstat (limited to 'sw/auth.py')
-rw-r--r--sw/auth.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/sw/auth.py b/sw/auth.py
index 2f03a04..85212ec 100644
--- a/sw/auth.py
+++ b/sw/auth.py
@@ -35,10 +35,25 @@ def load_logged_in_user():
)
+def json_input(view):
+ @functools.wraps(view)
+ def wrapped_view(**kwargs):
+ if not request.is_json:
+ return "Request body is not JSON", 422
+
+ return view(**kwargs)
+
+ return wrapped_view
+
+
+def from_trusted_server(view):
+ # TODO
+ return view
+
+
@bp.route("/register", methods=["POST"])
+@json_input
def register():
- if not request.is_json:
- return "Request body is not JSON", 422
data = request.json