Session¶
API endpoint for manage the current session.
Session management¶
/api/session
¶
-
GET
/storekeeper/api/session
¶ Get current session
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
Example request:
GET /storekeeper/api/session HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "admin": true, "disabled": false, "email": "admin@test.com", "id": 1, "username": "admin" }
-
POST
/storekeeper/api/session
¶ Login user
Status Codes: - 201 Created – no error
- 401 Unauthorized – bad authentication data or user is disabled
- 422 Unprocessable Entity – there is wrong type / missing field
Example request:
POST /storekeeper/api/session HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "password": "secret", "remember": false, "username": "admin" }
Example response:
HTTP/1.0 201 CREATED Content-Type: application/json { "admin": true, "disabled": false, "email": "admin@test.com", "id": 1, "username": "admin" }
-
DELETE
/storekeeper/api/session
¶ Logout user
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
Example request:
DELETE /storekeeper/api/session HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json null