refactor: merge auth(router) to account(router) and add auth to logout(router)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user