diff --git a/controllers/serverController.go b/controllers/serverController.go index 2df81e2..1145b62 100644 --- a/controllers/serverController.go +++ b/controllers/serverController.go @@ -40,15 +40,13 @@ func GetCorporation(c *fiber.Ctx) error { u := c.Locals("user").(models.User) - id := c.Params("id") - if u.UserType != "A" { return fiber.NewError(fiber.StatusUnauthorized, "Unauthorized: User is not admin") } - var corp models.Corporation + var corps []models.Corporation - database.DB.Find(&corp, "id = ?", id) + database.DB.Find(&corps) - return c.JSON(corp) + return c.JSON(corps) } diff --git a/routes/routes.go b/routes/routes.go index 299832f..1d7db5e 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -30,7 +30,7 @@ func Setup(app *fiber.App) { app.Post("/on_pub_stop", controllers.OnPubStop) app.Post("/on_sub_start", controllers.OnSubStart) - app.Get("/corporations/:id", controllers.GetCorporation) + app.Get("/corporations", controllers.GetCorporation) // Protected routes. Needs login before. protected := app.Group("/")