feat: serve quizzes:import over HTTP behind the shared user API token
POST /api/v1/quizzes/import runs behind golem15.user's user.api_token with the write scope and the golem15.quizzes.access_quizzes permission.
This commit is contained in:
@@ -240,6 +240,8 @@ The navigation item is "Quizzes" ("Quizy" in Polish). The admin's relation manag
|
||||
|---------|---------|
|
||||
| `quizzes:import <file.json> [--replace]` | Import one quiz from a JSON file. |
|
||||
|
||||
The same import is served over HTTP as `POST /api/v1/quizzes/import` (add `?replace=1` for `--replace`), with the import document as the body. The route runs behind the application-wide API token of `golem15.user` (`user.api_token`, created with `user:token:create`): the token needs the `write` scope and its user the `golem15.quizzes.access_quizzes` permission in one of their user groups. It answers `{"data": {"id", "slug", "created", "questions", "answers"}}`, 422 with a `message` for a document that does not parse, and 409 for an existing slug without `replace`. It needs a `golem15.user` that ships the shared API tokens.
|
||||
|
||||
The import runs in one transaction and is idempotent by slug:
|
||||
|
||||
- a new slug creates the quiz;
|
||||
|
||||
Reference in New Issue
Block a user