From a764e293fbb23bf2e5e94e1df745c6fc3c4d772b Mon Sep 17 00:00:00 2001 From: Leon <147289645+LeoninCS@users.noreply.github.com> Date: Fri, 5 Dec 2025 14:31:46 +0800 Subject: [PATCH] refactor: merge auth(router) to account(router) and add auth to logout(router) --- internal/http/router.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/http/router.go b/internal/http/router.go index 80dd157..13f7a80 100644 --- a/internal/http/router.go +++ b/internal/http/router.go @@ -17,20 +17,16 @@ func SetRouter(db *gorm.DB) *gin.Engine { accountGroup := r.Group("/account") { accountGroup.POST("/register", accountHandler.CreateAccount) - accountGroup.POST("/rename", accountHandler.RenameByID) + accountGroup.POST("/login", accountHandler.Login) accountGroup.POST("/changePassword", accountHandler.ChangePassword) accountGroup.POST("/findByID", accountHandler.FindByID) accountGroup.POST("/findByUsername", accountHandler.FindByUsername) } - authGroup := r.Group("/auth") + protectedAccountGroup := accountGroup.Group("") + protectedAccountGroup.Use(middleware.JWTAuth()) { - authGroup.POST("/login", accountHandler.Login) - } - - protectedAuthGroup := authGroup.Group("") - protectedAuthGroup.Use(middleware.JWTAuth()) - { - protectedAuthGroup.POST("/logout", accountHandler.Logout) + protectedAccountGroup.POST("/logout", accountHandler.Logout) + protectedAccountGroup.POST("/rename", accountHandler.RenameByID) } return r