debug logs for auth mw
All checks were successful
/ Make image (push) Successful in 1m11s

This commit is contained in:
nquidox 2026-03-25 22:29:28 +03:00
parent cafec373f1
commit 6d37d6a4f5

View file

@ -19,9 +19,11 @@ type Middlewares struct {
} }
func AuthMW(up UserProvider, ap AuthChecker, sid int32) gin.HandlerFunc { func AuthMW(up UserProvider, ap AuthChecker, sid int32) gin.HandlerFunc {
log.Debug("Auth Middlewares enabled") const funcHeader string = "Auth Middleware |"
log.Debugf("%v %v begin", pkgLogHeader, funcHeader)
return func(c *gin.Context) { return func(c *gin.Context) {
cookie, err := c.Cookie(tokenCookieName) cookie, err := c.Cookie(tokenCookieName)
log.WithField("value", cookie).Debugf("%v %v get session token from cookie", pkgLogHeader, funcHeader)
if err != nil { if err != nil {
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()}) c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
c.Abort() c.Abort()
@ -32,11 +34,13 @@ func AuthMW(up UserProvider, ap AuthChecker, sid int32) gin.HandlerFunc {
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()}) c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
c.Abort() c.Abort()
} }
log.WithField("value", userUuid).Debugf("%v %v get user uuid from auth service", pkgLogHeader, funcHeader)
log.Debugf("%v trying to get user id", pkgLogHeader)
userId, err := up.GetUserId(c, userUuid) userId, err := up.GetUserId(c, userUuid)
if err != nil { if err != nil {
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()}) c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
log.WithError(err).Errorf("%v error converting user uuid to user id: %v", pkgLogHeader, userUuid) log.WithError(err).Errorf("%v %v error converting user uuid to user id: %v", pkgLogHeader, funcHeader, userUuid)
return return
} }