diff options
| author | Tom Harley | 2021-07-10 21:41:09 +0000 |
|---|---|---|
| committer | Tom Harley | 2021-07-11 14:23:35 +0000 |
| commit | c4e848c21c028ca7c52846ea1abd7f3a38aff7d6 (patch) | |
| tree | fb886b06dcdd4d9ae4cc54ee9ea9f481ec124166 /sw/auth.py | |
| parent | Add basic inbox/outbox functionality (diff) | |
| download | swap-master.tar.gz swap-master.zip | |
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.
Diffstat (limited to 'sw/auth.py')
| -rw-r--r-- | sw/auth.py | 16 |
1 files changed, 4 insertions, 12 deletions
@@ -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): |
