Update docs and error message for sudo route
This commit is contained in:
parent
89062edc06
commit
6b2472924c
2 changed files with 11 additions and 3 deletions
|
@ -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()
|
||||||
|
|
10
docs/api.md
10
docs/api.md
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue