service id usage refactor

This commit is contained in:
nquidox 2026-04-01 17:48:12 +03:00
parent 7cef9cbe8d
commit e6da13e657
5 changed files with 19 additions and 21 deletions

View file

@ -8,9 +8,8 @@ import (
)
type DepsMW struct {
UserProv UserProvider
AuthProv AuthChecker
ServiceId int32
UserProv UserProvider
AuthProv AuthChecker
}
type Middlewares struct {
@ -18,7 +17,7 @@ type Middlewares struct {
RegMW gin.HandlerFunc
}
func AuthMW(up UserProvider, ap AuthChecker, sid int32) gin.HandlerFunc {
func AuthMW(up UserProvider, ap AuthChecker) gin.HandlerFunc {
const funcHeader string = "Auth Middleware |"
log.Debugf("%v %v begin", pkgLogHeader, funcHeader)
return func(c *gin.Context) {
@ -32,7 +31,7 @@ func AuthMW(up UserProvider, ap AuthChecker, sid int32) gin.HandlerFunc {
c.Abort()
}
userUuid, err := ap.VerifySession(c, cookie, sid)
userUuid, err := ap.VerifySession(c, cookie)
if err != nil {
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
c.Abort()
@ -53,7 +52,7 @@ func AuthMW(up UserProvider, ap AuthChecker, sid int32) gin.HandlerFunc {
}
}
func RegisterMW(ap AuthChecker, sid int32) gin.HandlerFunc {
func RegisterMW(ap AuthChecker) gin.HandlerFunc {
log.Debug("Auth Middlewares enabled")
return func(c *gin.Context) {
cookie, err := c.Cookie(tokenCookieName)
@ -63,7 +62,7 @@ func RegisterMW(ap AuthChecker, sid int32) gin.HandlerFunc {
return
}
userUuid, err := ap.VerifySession(c, cookie, sid)
userUuid, err := ap.VerifySession(c, cookie)
if err != nil {
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
c.Abort()