Skip to main content

Authentication

Endpoints for logging in, refreshing tokens, managing the current user's profile, and changing credentials.

Endpoints overview​

MethodEndpointPermissionDescription
POST/auth/loginβ€”Log in, receive tokens
POST/auth/refreshβ€”Refresh access token
POST/auth/logoutauthenticatedClear refresh token
GET/auth/meauthenticatedGet current user
PATCH/auth/meauthenticatedUpdate current user profile
PATCH/auth/change-passwordauthenticatedChange password
PATCH/auth/avatarauthenticatedUpload avatar
DELETE/auth/avatarauthenticatedDelete avatar

Endpoints​

Login​

POST /auth/login

Rate limited.

Request body

{ "login": "user@example.com", "password": "secret" }

Response β€” 200

{ "accessToken": "<jwt>" }

The refresh token is returned as an HttpOnly cookie.


Refresh token​

POST /auth/refresh

Rate limited. Reads the refresh token from the HttpOnly cookie and issues a new access token.

Response β€” 200

{ "accessToken": "<new_jwt>" }

Logout​

POST /auth/logout β€” Auth required

Clears the refresh token cookie server-side.

Response β€” 204


Get current user​

GET /auth/me β€” Auth required

Response β€” 200

{
"id": "a1b2c3d4-0000-0000-0000-000000000001",
"email": "jane@example.com",
"enName": "Jane",
"enSurname": "Smith",
"uaName": "Π”ΠΆΠ΅ΠΉΠ½",
"uaSurname": "Π‘ΠΌΡ–Ρ‚",
"roleId": "role-uuid",
"role": "Editor",
"avatarUrl": "/api/characters/file/avatars/jane.jpg",
"createdAt": "2025-01-10T09:00:00.000Z",
"permissions": [
{ "name": "episode:create", "scope": "global" },
{ "name": "scene:edit", "scope": "assigned" }
]
}

Update current user profile​

PATCH /auth/me β€” Auth required

Request body (all fields optional)

{
"enName": "Jane",
"enSurname": "Smith",
"uaName": "Π”ΠΆΠ΅ΠΉΠ½",
"uaSurname": "Π‘ΠΌΡ–Ρ‚",
"roleId": "role-uuid"
}

Response β€” 200 β€” updated user object (same shape as GET /auth/me)


Change password​

PATCH /auth/change-password β€” Auth required, Rate limited

All active sessions are revoked after a successful password change.

Request body

{
"currentPassword": "old_secret",
"newPassword": "new_secret"
}

Response β€” 204


Upload avatar​

PATCH /auth/avatar β€” Auth required, Rate limited, multipart/form-data

Form field: file β€” image file (JPEG / PNG)

Response β€” 200 β€” updated user object (same shape as GET /auth/me)


Delete avatar​

DELETE /auth/avatar β€” Auth required

Response β€” 200 β€” updated user object with avatarUrl: null