diff --git a/backend/internal/handlers/global_state.go b/backend/internal/handlers/global_state.go index 011d578..0d49610 100644 --- a/backend/internal/handlers/global_state.go +++ b/backend/internal/handlers/global_state.go @@ -34,6 +34,7 @@ type GlobalState interface { GetButtonCount(c *fiber.Ctx) error // For demonstration purposes IncrementButtonCount(c *fiber.Ctx) error // For demonstration purposes ListAllUsers(c *fiber.Ctx) error // To get a list of all users in the application database + ListAllUsersProject(c *fiber.Ctx) error // To get a list of all users for a specific project } // "Constructor" @@ -182,6 +183,7 @@ func (gs *GState) GetUserProjects(c *fiber.Ctx) error { return c.JSON(projects) } +// ListAllUsers is a handler that returns a list of all users in the application database func (gs *GState) ListAllUsers(c *fiber.Ctx) error { // Get all users from the database users, err := gs.Db.GetAllUsersApplication() @@ -192,3 +194,17 @@ func (gs *GState) ListAllUsers(c *fiber.Ctx) error { // Return the list of users as JSON return c.JSON(users) } + +func (gs *GState) ListAllUsersProject(c *fiber.Ctx) error { + // Extract the project name from the request parameters or body + projectName := c.Params("projectName") + + // Get all users associated with the project from the database + users, err := gs.Db.GetAllUsersProject(projectName) + if err != nil { + return c.Status(500).SendString(err.Error()) + } + + // Return the list of users as JSON + return c.JSON(users) +}