76 lines
941 B
Markdown
76 lines
941 B
Markdown
## POST /api/v1/auth/register
|
|
|
|
### Request:
|
|
|
|
```json
|
|
{
|
|
"username": "string",
|
|
"password": "string",
|
|
"email": "string?"
|
|
}
|
|
```
|
|
|
|
Registers a new user
|
|
|
|
### Response (success):
|
|
|
|
```json
|
|
{
|
|
"id": "string",
|
|
"username": "string",
|
|
"registerDate": "number"
|
|
}
|
|
```
|
|
|
|
### Response (error):
|
|
|
|
```json
|
|
{
|
|
"error": "user already exists"
|
|
}
|
|
```
|
|
|
|
## POST /api/v1/auth/login
|
|
|
|
### Request:
|
|
|
|
```json
|
|
{
|
|
"username": "string",
|
|
"password": "string"
|
|
}
|
|
```
|
|
|
|
Logs in a user and returns a new session cookie
|
|
|
|
### Response (success):
|
|
|
|
```json
|
|
{
|
|
"id": "string",
|
|
"ownerId": "string"
|
|
}
|
|
```
|
|
|
|
### Response (incorrect credentials):
|
|
|
|
```json
|
|
{
|
|
"username": "string",
|
|
"error": "incorrect credentials"
|
|
}
|
|
```
|
|
|
|
## GET /api/v1/auth/refresh
|
|
|
|
Creates and returns an authorization token for the current session using session cookie
|
|
|
|
### Response (success):
|
|
|
|
```json
|
|
{
|
|
"id": "string",
|
|
"ownerId": "string",
|
|
"token": "string"
|
|
}
|
|
```
|