fix: harden auth flows and align api contracts

This commit is contained in:
Your Name
2026-05-30 21:29:24 +08:00
parent 7ad65a0138
commit a332917142
50 changed files with 23594 additions and 723 deletions

View File

@@ -30,7 +30,7 @@ func NewTOTPHandler(authService *service.AuthService, totpService *service.TOTPS
// @Security BearerAuth
// @Success 200 {object} Response{data=TOTPStatusResponse} "TOTP状态"
// @Failure 401 {object} Response "未认证"
// @Router /api/v1/auth/totp/status [get]
// @Router /api/v1/auth/2fa/status [get]
func (h *TOTPHandler) GetTOTPStatus(c *gin.Context) {
userID, ok := getUserIDFromContext(c)
if !ok {
@@ -57,7 +57,7 @@ func (h *TOTPHandler) GetTOTPStatus(c *gin.Context) {
// @Success 200 {object} Response{data=TOTPSetupResponse} "TOTP设置信息"
// @Failure 401 {object} Response "未认证"
// @Failure 500 {object} Response "服务器错误"
// @Router /api/v1/auth/totp/setup [post]
// @Router /api/v1/auth/2fa/setup [get]
func (h *TOTPHandler) SetupTOTP(c *gin.Context) {
userID, ok := getUserIDFromContext(c)
if !ok {
@@ -94,7 +94,7 @@ func (h *TOTPHandler) SetupTOTP(c *gin.Context) {
// @Failure 400 {object} Response "请求参数错误"
// @Failure 401 {object} Response "未认证或验证码错误"
// @Failure 500 {object} Response "服务器错误"
// @Router /api/v1/auth/totp/enable [post]
// @Router /api/v1/auth/2fa/enable [post]
func (h *TOTPHandler) EnableTOTP(c *gin.Context) {
userID, ok := getUserIDFromContext(c)
if !ok {
@@ -131,7 +131,7 @@ func (h *TOTPHandler) EnableTOTP(c *gin.Context) {
// @Failure 400 {object} Response "请求参数错误"
// @Failure 401 {object} Response "未认证或验证码错误"
// @Failure 500 {object} Response "服务器错误"
// @Router /api/v1/auth/totp/disable [post]
// @Router /api/v1/auth/2fa/disable [post]
func (h *TOTPHandler) DisableTOTP(c *gin.Context) {
userID, ok := getUserIDFromContext(c)
if !ok {
@@ -168,7 +168,7 @@ func (h *TOTPHandler) DisableTOTP(c *gin.Context) {
// @Failure 400 {object} Response "请求参数错误"
// @Failure 401 {object} Response "未认证或验证码错误"
// @Failure 500 {object} Response "服务器错误"
// @Router /api/v1/auth/totp/verify [post]
// @Router /api/v1/auth/2fa/verify [post]
func (h *TOTPHandler) VerifyTOTP(c *gin.Context) {
userID, ok := getUserIDFromContext(c)
if !ok {