prefix for cookie path
This commit is contained in:
parent
404a52473d
commit
07c8a5bf35
3 changed files with 14 additions and 7 deletions
|
|
@ -66,9 +66,10 @@ func main() {
|
||||||
|
|
||||||
//register app modules
|
//register app modules
|
||||||
users := user.NewHandler(user.Deps{
|
users := user.NewHandler(user.Deps{
|
||||||
Auth: authProvider,
|
Auth: authProvider,
|
||||||
DB: database,
|
DB: database,
|
||||||
Utils: utilsProvider,
|
Utils: utilsProvider,
|
||||||
|
ApiPrefix: c.AppConf.ApiPrefix,
|
||||||
})
|
})
|
||||||
|
|
||||||
//collect modules
|
//collect modules
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"merch-parser-api/internal/interfaces"
|
"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)
|
userGroup.DELETE("/", authMW, h.controller.delete)
|
||||||
|
|
||||||
//auth
|
//auth
|
||||||
h.controller.authPath = "/user/auth"
|
h.controller.authPath = fmt.Sprintf("%s/user/auth", h.apiPrefix)
|
||||||
authGroup := userGroup.Group("/auth")
|
authGroup := userGroup.Group("/auth")
|
||||||
|
|
||||||
authGroup.POST("/login", h.controller.login)
|
authGroup.POST("/login", h.controller.login)
|
||||||
|
|
@ -213,6 +214,7 @@ func (co *controller) logout(c *gin.Context) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
||||||
log.WithError(err).Error("User | Failed to get refresh cookie")
|
log.WithError(err).Error("User | Failed to get refresh cookie")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshUuid := cookie.Value
|
refreshUuid := cookie.Value
|
||||||
|
|
@ -239,6 +241,7 @@ func (co *controller) refresh(c *gin.Context) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
||||||
log.WithError(err).Error("User | Failed to get refresh cookie")
|
log.WithError(err).Error("User | Failed to get refresh cookie")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshUuid := cookie.Value
|
refreshUuid := cookie.Value
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,14 @@ type Handler struct {
|
||||||
controller *controller
|
controller *controller
|
||||||
service *service
|
service *service
|
||||||
repo UserRepo
|
repo UserRepo
|
||||||
|
apiPrefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
Auth interfaces.Auth
|
Auth interfaces.Auth
|
||||||
DB *gorm.DB
|
DB *gorm.DB
|
||||||
Utils interfaces.Utils
|
Utils interfaces.Utils
|
||||||
|
ApiPrefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHandler(deps Deps) *Handler {
|
func NewHandler(deps Deps) *Handler {
|
||||||
|
|
@ -26,5 +28,6 @@ func NewHandler(deps Deps) *Handler {
|
||||||
controller: c,
|
controller: c,
|
||||||
service: s,
|
service: s,
|
||||||
repo: r,
|
repo: r,
|
||||||
|
apiPrefix: deps.ApiPrefix,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue