Update docs and error message for sudo route (#1117)
* Update docs and error message for sudo route * Fix Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
parent
07b7f40371
commit
aac493ad2f
|
@ -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()
|
||||
|
|
12
docs/api.md
12
docs/api.md
|
@ -10,7 +10,7 @@
|
|||
- [POST /api/auth/reactivate](##post-apiauthreactivate): Request a new activation code.
|
||||
- [POST /api/auth/forgot_password](#post-apiauthforgot_password): Request reset password link.
|
||||
- [GET /api/user_info](#get-apiuser_info): Get user's information.
|
||||
- [PATCH /api/sudo](#patch-apiuser_sudo): Enable sudo mode.
|
||||
- [PATCH /api/sudo](#patch-apisudo): Enable sudo mode.
|
||||
- [PATCH /api/user_info](#patch-apiuser_info): Update user's information.
|
||||
- [POST /api/api_key](#post-apiapi_key): Create a new API key.
|
||||
- [GET /api/logout](#get-apilogout): Log out.
|
||||
|
@ -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 is an error.
|
||||
|
||||
#### POST /api/api_key
|
||||
|
||||
|
|
Loading…
Reference in New Issue