Files
pangolin/server/migrations/000013_user_sub_token_totp.up.sql
T
wangjia 009dbb8d07 feat(server): web 用户中心后端(1/3) — GetMe 补字段 + logout + redeem 路径别名 + 用户表 totp/sub_token
为 web 用户中心接通真后端做准备(保持 snake_case 不破 app):
- migration 000013:users 加 sub_token / totp_secret_enc / totp_enabled。
- GetMe 扩展:补 devices_used/devices_max/quota_today_min/data_today_gb/
  weekly_gb/totp_enabled/expires_at(聚合 plans+usage_daily+devices+totp 列),
  保留原 expire_at 等字段不破 app。
- POST /v1/auth/logout:X-Refresh-Token 头 → RevokeRefresh,幂等 204。
- /v1/me/redeem 别名(web 用),保留 /v1/redeem(app 用)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 08:35:09 +08:00

11 lines
785 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Web 用户中心所需的用户级字段:
-- sub_token 个人订阅 URL 的不可猜测 tokenGET /v1/me/subscription 返回,
-- /sub/{token} 据此渲染该用户的 sing-box 订阅配置)。可轮换。
-- totp_secret_enc TOTP 密钥(AES-256-GCM 加密存储,复用 admin/crypto)。NULL=未设置。
-- totp_enabled 是否已启用两步验证(verify 通过后置 true)。
-- 全部可空/带默认,存量用户无需回填即生效(首次访问按需生成 sub_token)。
ALTER TABLE users
ADD COLUMN sub_token CHAR(36) NULL UNIQUE AFTER dp_uuid,
ADD COLUMN totp_secret_enc VARBINARY(255) NULL AFTER sub_token,
ADD COLUMN totp_enabled BOOLEAN NOT NULL DEFAULT FALSE AFTER totp_secret_enc;