diff --git a/app/api/views/sudo.py b/app/api/views/sudo.py index 04806f82..a6bb6e33 100644 --- a/app/api/views/sudo.py +++ b/app/api/views/sudo.py @@ -17,9 +17,9 @@ def enter_sudo(): user = g.user data = request.get_json() or {} if "password" not in data: - return jsonify(error="Invalid request"), 403 + return jsonify(error="Invalid password"), 403 if not user.check_password(data["password"]): - return jsonify(error="Invalid request"), 403 + return jsonify(error="Invalid password"), 403 g.api_key.sudo_mode_at = arrow.now() Session.commit() diff --git a/docs/api.md b/docs/api.md index 79a5fc33..a12fbd60 100644 --- a/docs/api.md +++ b/docs/api.md @@ -229,11 +229,19 @@ Enable sudo mode Input: +- `Authentication` header that contains the api key - password: User password to validate the user presence and enter sudo mode +```json +{ + "password": "yourpassword", +} +``` + Output: -- ok: True if sudo mode has been enabled +- 200 with ```{"ok": true}``` if sudo mode has been enabled. +- 403 with ```{"error": "Some error"} ``` if there's an error #### POST /api/api_key