Compare commits
No commits in common. "6d735c20cb5d8860dd8aa827145a377ee4901a62" and "9c143a43aaf468e7d7e24542c8fe3f1cb5e13fa3" have entirely different histories.
6d735c20cb
...
9c143a43aa
@ -11,7 +11,6 @@ import (
|
|||||||
"apskel-pos-be/internal/service"
|
"apskel-pos-be/internal/service"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/google/uuid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthMiddleware struct {
|
type AuthMiddleware struct {
|
||||||
@ -46,13 +45,9 @@ func (m *AuthMiddleware) RequireAuth() gin.HandlerFunc {
|
|||||||
setKeyInContext(c, appcontext.OrganizationIDKey, userResponse.OrganizationID.String())
|
setKeyInContext(c, appcontext.OrganizationIDKey, userResponse.OrganizationID.String())
|
||||||
setKeyInContext(c, appcontext.UserIDKey, userResponse.ID.String())
|
setKeyInContext(c, appcontext.UserIDKey, userResponse.ID.String())
|
||||||
|
|
||||||
// Always override OutletID from token to prevent header injection.
|
if userResponse.Role != "superadmin" {
|
||||||
// Set empty string if user has no outlet, so PopulateContext header value is ignored.
|
setKeyInContext(c, appcontext.OutletIDKey, userResponse.OutletID.String())
|
||||||
outletIDStr := ""
|
|
||||||
if userResponse.OutletID != nil && *userResponse.OutletID != uuid.Nil {
|
|
||||||
outletIDStr = userResponse.OutletID.String()
|
|
||||||
}
|
}
|
||||||
setKeyInContext(c, appcontext.OutletIDKey, outletIDStr)
|
|
||||||
|
|
||||||
logger.FromContext(c.Request.Context()).Infof("AuthMiddleware::RequireAuth -> User authenticated: %s", userResponse.Email)
|
logger.FromContext(c.Request.Context()).Infof("AuthMiddleware::RequireAuth -> User authenticated: %s", userResponse.Email)
|
||||||
c.Next()
|
c.Next()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user