diff --git a/cmd/main.go b/cmd/main.go index 14cd0bd..a002857 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -66,9 +66,10 @@ func main() { //register app modules users := user.NewHandler(user.Deps{ - Auth: authProvider, - DB: database, - Utils: utilsProvider, + Auth: authProvider, + DB: database, + Utils: utilsProvider, + ApiPrefix: c.AppConf.ApiPrefix, }) //collect modules diff --git a/internal/api/user/controller.go b/internal/api/user/controller.go index cf1105e..93bc5e2 100644 --- a/internal/api/user/controller.go +++ b/internal/api/user/controller.go @@ -1,6 +1,7 @@ package user import ( + "fmt" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" "merch-parser-api/internal/interfaces" @@ -32,7 +33,7 @@ func (h *Handler) RegisterRoutes(r *gin.RouterGroup, authMW gin.HandlerFunc) { userGroup.DELETE("/", authMW, h.controller.delete) //auth - h.controller.authPath = "/user/auth" + h.controller.authPath = fmt.Sprintf("%s/user/auth", h.apiPrefix) authGroup := userGroup.Group("/auth") authGroup.POST("/login", h.controller.login) @@ -213,6 +214,7 @@ func (co *controller) logout(c *gin.Context) { if err != nil { c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()}) log.WithError(err).Error("User | Failed to get refresh cookie") + return } refreshUuid := cookie.Value @@ -239,6 +241,7 @@ func (co *controller) refresh(c *gin.Context) { if err != nil { c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()}) log.WithError(err).Error("User | Failed to get refresh cookie") + return } refreshUuid := cookie.Value diff --git a/internal/api/user/handler.go b/internal/api/user/handler.go index 2b0c143..f4dea02 100644 --- a/internal/api/user/handler.go +++ b/internal/api/user/handler.go @@ -9,12 +9,14 @@ type Handler struct { controller *controller service *service repo UserRepo + apiPrefix string } type Deps struct { - Auth interfaces.Auth - DB *gorm.DB - Utils interfaces.Utils + Auth interfaces.Auth + DB *gorm.DB + Utils interfaces.Utils + ApiPrefix string } func NewHandler(deps Deps) *Handler { @@ -26,5 +28,6 @@ func NewHandler(deps Deps) *Handler { controller: c, service: s, repo: r, + apiPrefix: deps.ApiPrefix, } }