refactor: merge auth(router) to account(router) and add auth to logout(router)

This commit is contained in:
Leon
2025-12-05 14:31:46 +08:00
parent 748d4dd719
commit a764e293fb

View File

@@ -17,20 +17,16 @@ func SetRouter(db *gorm.DB) *gin.Engine {
accountGroup := r.Group("/account") accountGroup := r.Group("/account")
{ {
accountGroup.POST("/register", accountHandler.CreateAccount) accountGroup.POST("/register", accountHandler.CreateAccount)
accountGroup.POST("/rename", accountHandler.RenameByID) accountGroup.POST("/login", accountHandler.Login)
accountGroup.POST("/changePassword", accountHandler.ChangePassword) accountGroup.POST("/changePassword", accountHandler.ChangePassword)
accountGroup.POST("/findByID", accountHandler.FindByID) accountGroup.POST("/findByID", accountHandler.FindByID)
accountGroup.POST("/findByUsername", accountHandler.FindByUsername) accountGroup.POST("/findByUsername", accountHandler.FindByUsername)
} }
authGroup := r.Group("/auth") protectedAccountGroup := accountGroup.Group("")
protectedAccountGroup.Use(middleware.JWTAuth())
{ {
authGroup.POST("/login", accountHandler.Login) protectedAccountGroup.POST("/logout", accountHandler.Logout)
} protectedAccountGroup.POST("/rename", accountHandler.RenameByID)
protectedAuthGroup := authGroup.Group("")
protectedAuthGroup.Use(middleware.JWTAuth())
{
protectedAuthGroup.POST("/logout", accountHandler.Logout)
} }
return r return r