fix validation rules so description_hash works.

This commit is contained in:
fiatjaf
2020-07-04 22:28:08 -03:00
parent bc27293315
commit 24dc6e5415
6 changed files with 9 additions and 17 deletions
+2 -2
View File
@@ -36,7 +36,7 @@ def api_validate_post_request(*, schema: dict):
return jsonify({"message": "Content-Type must be `application/json`."}), HTTPStatus.BAD_REQUEST
v = Validator(schema)
g.data = {key: (request.json[key] if key in request.json else None) for key in schema.keys()}
g.data = {key: request.json[key] for key in schema.keys() if key in request.json}
if not v.validate(g.data):
return jsonify({"message": f"Errors in request data: {v.errors}"}), HTTPStatus.BAD_REQUEST
@@ -56,7 +56,7 @@ def check_user_exists(param: str = "usr"):
allowed_users = getenv("LNBITS_ALLOWED_USERS", "all")
if allowed_users != "all" and g.user.id not in allowed_users.split(","):
abort(HTTPStatus.UNAUTHORIZED, f"User not authorized.")
abort(HTTPStatus.UNAUTHORIZED, "User not authorized.")
return view(**kwargs)