service.xpcool.com/internal/library/response/http.go
夏犀麟 3d24dbd8cb feat(auth): 认证链路联调修复——401 语义化 + 登出撤销会话 + 零配置兜底
- 未授权响应改为 HTTP 401(原 200+code10002 vben 拦截器不识别,
  token 过期永远不触发静默刷新/重登)
- 新增 response.JSONWithStatus;三处 401(UserAuth/AdminAuthOnly/AdminAuth)切换
- LogoutReq 支持 refreshToken:登出时撤销刷新会话(幂等),阻止设备续期;
  Refresh 时顺带清理已过期会话行
- IAdminAuth 新增 Revoke;dao/internal/admin_user.go 补 bark_device_id/
  pushplus_token 列映射(与 016 SQL/0569c70 对齐,恢复 int/gtime 类型映射)
- injectEnv 开发模式兜底: 等占位符未注入 env 时回填本地默认 DSN,
  任何启动方式(GoLand/命令行/go run)零配置可跑;prod 不兜底
2026-08-27 23:00:53 +08:00

12 lines
518 B
Go
Raw Permalink 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.

package response
import "github.com/gogf/gf/v2/net/ghttp"
// JSONWithStatus 输出带 HTTP 状态码的统一 JSON 信封。
// 401 等需要触发前端认证拦截器vben 仅识别 HTTP 401的场景必须用它
// 普通业务错误仍用 JSONHTTP 200 + code 区分),避免前端按异常处理。
func JSONWithStatus(r *ghttp.Request, httpStatus, code int, message string, data any) {
r.Response.WriteStatus(httpStatus)
r.Response.WriteJsonExit(Body{Code: code, Message: message, Data: data})
}