fix: resolve build errors (undefined generateRandomUUID, shadowed auth package) and update .gitignore

This commit is contained in:
Haitao Pan 2026-02-02 20:29:10 +08:00
parent 693889f366
commit 8afd3e5b8f
3 changed files with 16 additions and 11 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
.env
account.log
models/
pg_jieba/
hf_cache/

View File

@ -5,6 +5,7 @@ import (
"time"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
func (h *handler) pauseUser(c *gin.Context) {
@ -163,3 +164,7 @@ func (h *handler) removeFromBlacklist(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "email removed from blacklist"})
}
func generateRandomUUID() string {
return uuid.New().String()
}

View File

@ -229,26 +229,26 @@ func RegisterRoutes(r *gin.Engine, opts ...Option) {
c.JSON(http.StatusOK, gin.H{"status": "ok"})
})
auth := r.Group("/api/auth")
authGroup := r.Group("/api/auth")
auth.POST("/register", h.register)
auth.POST("/register/verify", h.verifyEmail)
auth.POST("/register/send", h.sendEmailVerification)
authGroup.POST("/register", h.register)
authGroup.POST("/register/verify", h.verifyEmail)
authGroup.POST("/register/send", h.sendEmailVerification)
auth.POST("/login", h.login)
authGroup.POST("/login", h.login)
// Token exchange endpoint - converts public token to access/refresh tokens
auth.POST("/token/exchange", h.exchangeToken)
authGroup.POST("/token/exchange", h.exchangeToken)
// OAuth2 routes
auth.GET("/oauth/login/:provider", h.oauthLogin)
auth.GET("/oauth/callback/:provider", h.oauthCallback)
authGroup.GET("/oauth/login/:provider", h.oauthLogin)
authGroup.GET("/oauth/callback/:provider", h.oauthCallback)
// Token refresh endpoint - generates new access token using refresh token
auth.POST("/token/refresh", h.refreshToken)
authGroup.POST("/token/refresh", h.refreshToken)
// Protected routes requiring authentication
authProtected := auth.Group("")
authProtected := authGroup.Group("")
if h.tokenService != nil {
authProtected.Use(h.tokenService.AuthMiddleware())
authProtected.Use(auth.RequireActiveUser(h.store))