diff --git a/backend/middleware/auth/auth.go b/backend/middleware/auth/auth.go index 1d59b9a7..6130a165 100644 --- a/backend/middleware/auth/auth.go +++ b/backend/middleware/auth/auth.go @@ -4,6 +4,7 @@ import ( "slices" "time" + "github.com/GenerateNU/sac/backend/locals" "github.com/GenerateNU/sac/backend/permission" "github.com/GenerateNU/sac/backend/entities/models" @@ -33,6 +34,7 @@ func (m *AuthMiddlewareHandler) Authorize(requiredPermissions ...permission.Perm user := models.UnmarshalUser(strUser) if user.Role == models.Super { + locals.SetUser(c, user) return c.Next() } @@ -44,6 +46,7 @@ func (m *AuthMiddlewareHandler) Authorize(requiredPermissions ...permission.Perm } } + locals.SetUser(c, user) return c.Next() } } diff --git a/backend/middleware/auth/club.go b/backend/middleware/auth/club.go index f37b89cf..54d42980 100644 --- a/backend/middleware/auth/club.go +++ b/backend/middleware/auth/club.go @@ -7,6 +7,7 @@ import ( "github.com/GenerateNU/sac/backend/entities/clubs" "github.com/GenerateNU/sac/backend/entities/models" "github.com/GenerateNU/sac/backend/integrations/oauth/soth/sothic" + "github.com/GenerateNU/sac/backend/locals" "github.com/GenerateNU/sac/backend/utilities" "github.com/gofiber/fiber/v2" ) @@ -29,6 +30,7 @@ func (m *AuthMiddlewareHandler) ClubAuthorizeById(c *fiber.Ctx, extractor Extrac user := models.UnmarshalUser(strUser) if user.Role == models.Super { + locals.SetUser(c, user) return c.Next() } @@ -43,6 +45,7 @@ func (m *AuthMiddlewareHandler) ClubAuthorizeById(c *fiber.Ctx, extractor Extrac } if slices.Contains(clubAdmin, user.ID) { + locals.SetUser(c, user) return c.Next() } diff --git a/backend/middleware/auth/event.go b/backend/middleware/auth/event.go index 443c4b6e..61945493 100644 --- a/backend/middleware/auth/event.go +++ b/backend/middleware/auth/event.go @@ -7,6 +7,7 @@ import ( "github.com/GenerateNU/sac/backend/entities/events" "github.com/GenerateNU/sac/backend/entities/models" "github.com/GenerateNU/sac/backend/integrations/oauth/soth/sothic" + "github.com/GenerateNU/sac/backend/locals" "github.com/GenerateNU/sac/backend/utilities" "github.com/gofiber/fiber/v2" @@ -41,6 +42,7 @@ func (m *AuthMiddlewareHandler) EventAuthorizeById(c *fiber.Ctx, extractor Extra } if slices.Contains(eventHostAdmin, user.ID) { + locals.SetUser(c, user) return c.Next() } diff --git a/backend/middleware/auth/user.go b/backend/middleware/auth/user.go index 38b65f33..c9ab0107 100644 --- a/backend/middleware/auth/user.go +++ b/backend/middleware/auth/user.go @@ -5,6 +5,7 @@ import ( "github.com/GenerateNU/sac/backend/entities/models" "github.com/GenerateNU/sac/backend/integrations/oauth/soth/sothic" + "github.com/GenerateNU/sac/backend/locals" "github.com/GenerateNU/sac/backend/utilities" "github.com/gofiber/fiber/v2" ) @@ -27,6 +28,7 @@ func (m *AuthMiddlewareHandler) UserAuthorizeById(c *fiber.Ctx) error { user := models.UnmarshalUser(strUser) if user.Role == models.Super { + locals.SetUser(c, user) return c.Next() } @@ -36,6 +38,7 @@ func (m *AuthMiddlewareHandler) UserAuthorizeById(c *fiber.Ctx) error { } if idAsUUID == &user.ID { + locals.SetUser(c, user) return c.Next() }