main
nilo 2024-11-24 10:40:59 -03:00
parent 7983421371
commit 984c185a9c
2 changed files with 4 additions and 6 deletions

View File

@ -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)
}

View File

@ -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("/")