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>
This commit is contained in:
@@ -261,6 +261,15 @@ func (s *Service) Login(ctx context.Context, rawEmail, password, ip string) (*To
|
||||
return pair, 0, nil
|
||||
}
|
||||
|
||||
// Logout revokes the given refresh token. Idempotent: an empty, unknown, or
|
||||
// malformed token is a no-op (the client clears its own session regardless).
|
||||
func (s *Service) Logout(ctx context.Context, refreshToken string) {
|
||||
if refreshToken == "" {
|
||||
return
|
||||
}
|
||||
_ = s.tokens.RevokeRefresh(ctx, refreshToken)
|
||||
}
|
||||
|
||||
// Refresh validates and rotates a refresh token.
|
||||
func (s *Service) Refresh(ctx context.Context, refreshToken string) (*TokenPair, *apierr.Error) {
|
||||
if refreshToken == "" {
|
||||
|
||||
Reference in New Issue
Block a user