auth MW refactor
This commit is contained in:
parent
a7530a6324
commit
0903bc55eb
7 changed files with 15 additions and 148 deletions
|
|
@ -23,27 +23,28 @@ func newController(service *service, utils interfaces.Utils) *controller {
|
|||
}
|
||||
}
|
||||
|
||||
func (h *Handler) RegisterRoutes(r *gin.RouterGroup) {
|
||||
func (h *Handler) RegisterRoutes(r *gin.RouterGroup, authMW gin.HandlerFunc) {
|
||||
userGroup := r.Group("/user")
|
||||
|
||||
userGroup.POST("/", h.controller.register)
|
||||
userGroup.GET("/", h.controller.get)
|
||||
userGroup.PUT("/", h.controller.update)
|
||||
userGroup.DELETE("/", h.controller.delete)
|
||||
userGroup.POST("/", authMW, h.controller.register)
|
||||
userGroup.GET("/", authMW, h.controller.get)
|
||||
userGroup.PUT("/", authMW, h.controller.update)
|
||||
userGroup.DELETE("/", authMW, h.controller.delete)
|
||||
|
||||
//auth
|
||||
h.controller.authPath = "/user/auth"
|
||||
|
||||
authGroup := userGroup.Group("/auth")
|
||||
|
||||
authGroup.POST("/login", h.controller.login)
|
||||
authGroup.POST("/logout", h.controller.logout)
|
||||
authGroup.POST("/logout", authMW, h.controller.logout)
|
||||
authGroup.POST("/refresh", h.controller.refresh)
|
||||
}
|
||||
|
||||
func (h *Handler) ExcludeRoutes() []shared.ExcludeRoute {
|
||||
return []shared.ExcludeRoute{
|
||||
{Route: "/user", Method: http.MethodPost},
|
||||
{Route: "/user/login", Method: http.MethodPost},
|
||||
{Route: "/user/auth/login", Method: http.MethodPost},
|
||||
{Route: "/user/auth/refresh", Method: http.MethodPost},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue