1.5 KiB
1.5 KiB
认证API
认证API位于 backend/app/api/auth.py
端点列表
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /api/v1/auth/register | 用户注册 |
| POST | /api/v1/auth/login | 用户登录 |
| POST | /api/v1/auth/logout | 用户登出 |
| GET | /api/v1/auth/me | 获取当前用户 |
| PUT | /api/v1/auth/me | 更新当前用户 |
| POST | /api/v1/auth/refresh | 刷新Token |
| POST | /api/v1/auth/forgot-password | 忘记密码 |
| POST | /api/v1/auth/reset-password | 重置密码 |
注册
POST /api/v1/auth/register
请求体
{
"email": "user@example.com",
"username": "username",
"password": "password123",
"password_confirm": "password123"
}
响应
{
"success": true,
"data": {
"id": "uuid",
"email": "user@example.com",
"username": "username",
"created_at": "2024-01-01T00:00:00Z"
}
}
登录
POST /api/v1/auth/login
请求体
{
"email": "user@example.com",
"password": "password123"
}
响应
{
"success": true,
"data": {
"access_token": "eyJ...",
"refresh_token": "eyJ...",
"token_type": "bearer",
"expires_in": 86400
}
}
获取当前用户
GET /api/v1/auth/me
响应
{
"success": true,
"data": {
"id": "uuid",
"email": "user@example.com",
"username": "username",
"role": "user",
"subscription_tier": "pro",
"created_at": "2024-01-01T00:00:00Z"
}
}