Update docs and error message for sudo route

This commit is contained in:
Adrià Casajús 2022-06-28 13:05:41 +02:00
parent 89062edc06
commit 6b2472924c
No known key found for this signature in database
GPG key ID: F0033226A5AFC9B9
2 changed files with 11 additions and 3 deletions

View file

@ -17,9 +17,9 @@ def enter_sudo():
user = g.user user = g.user
data = request.get_json() or {} data = request.get_json() or {}
if "password" not in data: if "password" not in data:
return jsonify(error="Invalid request"), 403 return jsonify(error="Invalid password"), 403
if not user.check_password(data["password"]): 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() g.api_key.sudo_mode_at = arrow.now()
Session.commit() Session.commit()

View file

@ -229,11 +229,19 @@ Enable sudo mode
Input: Input:
- `Authentication` header that contains the api key
- password: User password to validate the user presence and enter sudo mode - password: User password to validate the user presence and enter sudo mode
```json
{
"password": "yourpassword",
}
```
Output: 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 #### POST /api/api_key