GITBOOK-7: No subject

This commit is contained in:
stalcke2288969
2025-07-24 11:39:54 +00:00
committed by gitbook-bot
parent a0ef087110
commit e217716604
3 changed files with 155 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
# Page
+29
View File
@@ -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\<T>](../code-docs/hubresult-less-than-t-greater-than.md)
+126
View File
@@ -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
#### <mark style="color:$info;">GetAllSessions</mark>
* **Description**: Retrieves all active sessions for the authenticated user.
* **Route**: `[GET] api/session/all`
* **HTTP Method**: `GET`
* **Request**: None
* **Responses**:
* <mark style="color:$success;">**200 OK**</mark>: Returns a list of user sessions.
```json
[
{
"id": "Guid",
"deviceInfo": "string",
"createdAt": "DateTime",
"expiresAt": "DateTime",
"isRevoked": "boolean"
}
]
```
* <mark style="color:$danger;">**403 Forbidden**</mark>: If user lacks authorization.
```json
"string"
```
* <mark style="color:$warning;">**500 Internal Server Error**</mark>: Indicates an unexpected error.
```json
"Unexpected Error! Please try again later."
```
#### <mark style="color:$info;">CloseSession</mark>
* **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**:
* <mark style="color:$success;">**200 OK**</mark>: Indicates session was successfully closed.
* No body.
* <mark style="color:$danger;">**400 Bad Request**</mark>: If `sessionId` is invalid or operation fails.
```json
"string"
```
* <mark style="color:$danger;">**403 Forbidden**</mark>: If user lacks authorization.
```json
"string"
```
* <mark style="color:$danger;">**404 Not Found**</mark>: If session is not found.
```json
"string"
```
* <mark style="color:$warning;">**500 Internal Server Error**</mark>: Indicates an unexpected error.
```json
"Unexpected Error! Please try again later."
```
#### <mark style="color:$info;">CloseAllSessions</mark>
* **Description**: Closes all active sessions for the authenticated user.
* **Route**: `[DELETE] api/session/close/all`
* **HTTP Method**: `DELETE`
* **Request**: None
* **Responses**:
* <mark style="color:$success;">**200 OK**</mark>: Indicates all sessions were successfully closed.
* No body.
* <mark style="color:$danger;">**403 Forbidden**</mark>: If user lacks authorization.
```json
"string"
```
* <mark style="color:$danger;">**500 Internal Server Error**</mark>: 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.