diff --git a/README.md b/docs/README.md similarity index 100% rename from README.md rename to docs/README.md diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md new file mode 100644 index 0000000..145002e --- /dev/null +++ b/docs/SUMMARY.md @@ -0,0 +1,29 @@ +# Table of contents + +* [Page](README.md) + +## Endpoints + +* [Authentication](../endpoints/authentication/README.md) + * [AuthController](../endpoints/authentication/authcontroller.md) + * [RefreshController](../endpoints/authentication/refreshcontroller.md) +* [SessionController](endpoints/sessioncontroller.md) +* [FriendshipController](../endpoints/friendshipcontroller.md) +* [FriendsRequestQueryController](../endpoints/friendsrequestquerycontroller.md) +* [MediaController](../endpoints/mediacontroller.md) +* [ChatLoadController](../endpoints/chatloadcontroller.md) +* [OnlinePingingController(не работает)](../endpoints/onlinepingingcontroller-ne-rabotaet.md) + +## SignalR + +* [PresenceHub](../signalr/presencehub.md) +* [ChatHub](../signalr/chathub.md) + +*** + +* [FriendsHub](../friendshub/README.md) + * [FriendsHub Client (Java)](../friendshub/friendshub-client-java.md) + +## Code Docs + +* [HubResult\](../code-docs/hubresult-less-than-t-greater-than.md) diff --git a/docs/endpoints/sessioncontroller.md b/docs/endpoints/sessioncontroller.md new file mode 100644 index 0000000..afb2b05 --- /dev/null +++ b/docs/endpoints/sessioncontroller.md @@ -0,0 +1,126 @@ +--- +description: >- + Controller for managing user sessions, including retrieving and closing + sessions. +--- + +# SessionController + +### Controller Description + +* **Route**: `api/session` +* **Authorize**: Requires authenticated user with roles "Admin" or "User" (`[Authorize(Roles = "Admin,User")]`). + +### Endpoints + +#### GetAllSessions + +* **Description**: Retrieves all active sessions for the authenticated user. +* **Route**: `[GET] api/session/all` +* **HTTP Method**: `GET` +* **Request**: None +* **Responses**: + * **200 OK**: Returns a list of user sessions. + + ```json + [ + { + "id": "Guid", + "deviceInfo": "string", + "createdAt": "DateTime", + "expiresAt": "DateTime", + "isRevoked": "boolean" + } + ] + ``` + * **403 Forbidden**: If user lacks authorization. + + ```json + "string" + ``` + * **500 Internal Server Error**: Indicates an unexpected error. + + ```json + "Unexpected Error! Please try again later." + ``` + +#### CloseSession + +* **Description**: Closes a specific session for the authenticated user. +* **Route**: `[DELETE] api/session/close/{sessionId}` +* **HTTP Method**: `DELETE` +* **Request**: + * **Path Parameter**: `sessionId` (Guid, required): ID of the session to close. +* **Responses**: + * **200 OK**: Indicates session was successfully closed. + * No body. + * **400 Bad Request**: If `sessionId` is invalid or operation fails. + + ```json + "string" + ``` + * **403 Forbidden**: If user lacks authorization. + + ```json + "string" + ``` + * **404 Not Found**: If session is not found. + + ```json + "string" + ``` + * **500 Internal Server Error**: Indicates an unexpected error. + + ```json + "Unexpected Error! Please try again later." + ``` + +#### CloseAllSessions + +* **Description**: Closes all active sessions for the authenticated user. +* **Route**: `[DELETE] api/session/close/all` +* **HTTP Method**: `DELETE` +* **Request**: None +* **Responses**: + * **200 OK**: Indicates all sessions were successfully closed. + * No body. + * **403 Forbidden**: If user lacks authorization. + + ```json + "string" + ``` + * **500 Internal Server Error**: Indicates an unexpected error. + + ```json + "Unexpected Error! Please try again later." + ``` + +### Data Models + +#### SessionDto + +* **Description**: Data transfer object for session information. +* **Structure**: + + ```json + { + "id": "Guid", + "deviceInfo": "string", + "createdAt": "DateTime", + "expiresAt": "DateTime", + "isRevoked": "boolean" + } + ``` + +### Error Handling + +* **Invalid User ID**: Handled by `ICurrentUserService`, aborts if invalid. +* **Invalid Operations**: Returns `400 Bad Request` for `InvalidOperationException`. +* **Unauthorized Access**: Returns `403 Forbidden` for `UnauthorizedAccessException`. +* **Resource Not Found**: Returns `404 Not Found` for `NotFoundException`. +* **Unexpected Errors**: Caught and returned as `500 Internal Server Error`. + +### Logging + +* Logs warnings for `UnauthorizedAccessException` and `NotFoundException`. +* Logs errors for `InvalidOperationException` and unexpected exceptions.