From c4e848c21c028ca7c52846ea1abd7f3a38aff7d6 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Sat, 10 Jul 2021 21:41:09 +0000 Subject: Add more inbox/outbox tests Still not even total coverage! Need to: - write more tests for outbox manipulation - look into and implement receiving content from other servers (+ write tests) off the top of my head. --- sw/auth.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'sw/auth.py') diff --git a/sw/auth.py b/sw/auth.py index 85212ec..4fd0f68 100644 --- a/sw/auth.py +++ b/sw/auth.py @@ -57,14 +57,8 @@ def register(): data = request.json - if "username" not in data: - return "Username required", 400 - - if "password" not in data: - return "Password required", 400 - - username = data["username"] - password = data["password"] + username = data.get("username") + password = data.get("password") if username is None: return "Username required", 400 @@ -99,17 +93,15 @@ def register(): @bp.route("/login", methods=["POST"]) +@json_input def login(): - if not request.is_json: - return "Request body is not JSON", 422 - username = request.json["username"] password = request.json["password"] db = get_db() user = db.execute("select * from users where username=?", (username,)).fetchone() - if user is None: + if (user is None) or (password is None): return "Username or password incorrect", 403 if not check_password_hash(user["password"], password): -- cgit v1.2.1