身份验证
MenuGaze 使用基于 JWT 的身份验证。所有需要身份验证的端点都要求在 Authorization 请求头中提供有效的 Bearer 令牌。令牌通过下方的身份验证端点登录获取。
POST /api/auth/signup
创建新账户。
身份验证:公开(无需令牌)
速率限制:每个 IP 每 15 分钟 10 次请求
请求体
{
"name": "Jane Smith",
"email": "jane@example.com",
"password": "securepassword123",
"restaurantName": "Jane's Bistro"
}
响应(201 Created)
{
"success": true,
"data": {
"user": {
"id": "uuid",
"name": "Jane Smith",
"email": "jane@example.com"
},
"token": "eyJhbGciOiJIUzI1NiIs..."
}
}
POST /api/auth/login
使用现有账户登录。
身份验证:公开(无需令牌)
速率限制:每个 IP 每 15 分钟 10 次请求
请求体
{
"email": "jane@example.com",
"password": "securepassword123"
}
响应(200 OK)
{
"success": true,
"data": {
"user": {
"id": "uuid",
"name": "Jane Smith",
"email": "jane@example.com"
},
"token": "eyJhbGciOiJIUzI1NiIs..."
}
}
使用令牌
在所有需要身份验证的请求中,将令牌包含在 Authorization 请求头中:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
错误响应
- 400 — 请求体中缺少字段或字段无效。
- 401 — 电子邮件或密码无效。
- 429 — 超出速率限制。请查看
Retry-After请求头,了解需等待多少秒后才能重试。