docs: 修正 verify_token 为简单随机字符串非JWT

verify_token 使用 32 位随机字符串(vtf_xxx)而非 JWT,
避免签名验证的复杂性,直接 Redis 比对即可。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
zheng020 2026-05-22 13:13:56 +08:00
parent 72ea3f4305
commit 95d8c75500

View File

@ -243,25 +243,26 @@ Content-Type: application/json
"message": "验证成功", "message": "验证成功",
"data": { "data": {
"verified": true, "verified": true,
"verify_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "verify_token": "vtf_abc123xyz789...",
"expires_in": 300 "expires_in": 300
} }
} }
``` ```
**说明** **说明**
- `verify_token` 用于后续注册接口的认证,后端在 Redis 中记录 `verify:register:{mobile}` = verify_token - `verify_token` 是长度为 32 位的随机字符串(格式:`vtf_` + 29 位随机字符),不是 JWT
- 存储在 Redis 中:`verify:register:{mobile}` → `vtf_abc123xyz789...`TTL = 300 秒
- 注册接口需携带此 token验证通过后才处理注册请求 - 注册接口需携带此 token验证通过后才处理注册请求
- `expires_in` = 300 秒5 分钟),超时需重新验证 - 验证成功后删除该记录,防止重复使用
**注册接口携带 token** **注册接口携带 token**
``` ```
POST /api/v1/auth/register POST /api/v1/auth/register
Authorization: Bearer {verify_token}
Content-Type: application/json Content-Type: application/json
{ {
"mobile": "13800138000", "mobile": "13800138000",
"verify_token": "vtf_abc123xyz789...",
"password": "xxx", "password": "xxx",
"nickname": "xxx", "nickname": "xxx",
"star_id": 1 "star_id": 1
@ -269,8 +270,8 @@ Content-Type: application/json
``` ```
后端逻辑: 后端逻辑:
1. 从 verify_token 中解析出 mobile 1. 根据 mobile 从 Redis 中获取 `verify:register:{mobile}` 的值
2. 检查 Redis 中 `verify:register:{mobile}` 是否与 token 匹配 2. 与请求中的 verify_token 比对,不一致则拒绝
3. 验证通过后删除该记录,防止重复使用 3. 验证通过后删除该记录,防止重复使用
--- ---