From 34ad6ac777ad9815c594c936052b83fb9ead9747 Mon Sep 17 00:00:00 2001 From: dDogge <> Date: Thu, 14 Mar 2024 22:48:06 +0100 Subject: [PATCH] Handler ListAllUsers in global_state.go added for GetAllUserApplication in db.go --- backend/internal/handlers/global_state.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/internal/handlers/global_state.go b/backend/internal/handlers/global_state.go index 0f3fcc0..011d578 100644 --- a/backend/internal/handlers/global_state.go +++ b/backend/internal/handlers/global_state.go @@ -33,6 +33,7 @@ type GlobalState interface { // SignCollection(c *fiber.Ctx) error // To sign a collection 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 } // "Constructor" @@ -180,3 +181,14 @@ func (gs *GState) GetUserProjects(c *fiber.Ctx) error { // Return a json serialized list of projects return c.JSON(projects) } + +func (gs *GState) ListAllUsers(c *fiber.Ctx) error { + // Get all users from the database + users, err := gs.Db.GetAllUsersApplication() + if err != nil { + return c.Status(500).SendString(err.Error()) + } + + // Return the list of users as JSON + return c.JSON(users) +}