From 553a87ab78226ecfa665f0d7351a21c8543a39e2 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 2 Nov 2024 14:05:42 +0800 Subject: [PATCH] :bug: Fix publisher api didn't ensure auth cause crash --- pkg/internal/http/api/publishers_api.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/internal/http/api/publishers_api.go b/pkg/internal/http/api/publishers_api.go index ab623e7..186e3c8 100644 --- a/pkg/internal/http/api/publishers_api.go +++ b/pkg/internal/http/api/publishers_api.go @@ -2,6 +2,7 @@ package api import ( "fmt" + "git.solsynth.dev/hypernet/interactive/pkg/internal/database" "git.solsynth.dev/hypernet/interactive/pkg/internal/gap" "git.solsynth.dev/hypernet/interactive/pkg/internal/http/exts" @@ -47,6 +48,9 @@ func getPublisher(c *fiber.Ctx) error { } func listOwnedPublisher(c *fiber.Ctx) error { + if err := sec.EnsureAuthenticated(c); err != nil { + return err + } user := c.Locals("user").(authm.Account) var publishers []models.Publisher @@ -100,6 +104,9 @@ func createOrganizationPublisher(c *fiber.Ctx) error { } func editPublisher(c *fiber.Ctx) error { + if err := sec.EnsureAuthenticated(c); err != nil { + return err + } user := c.Locals("user").(authm.Account) id, _ := c.ParamsInt("publisherId", 0) @@ -138,6 +145,9 @@ func editPublisher(c *fiber.Ctx) error { } func deletePublisher(c *fiber.Ctx) error { + if err := sec.EnsureAuthenticated(c); err != nil { + return err + } user := c.Locals("user").(authm.Account) id, _ := c.ParamsInt("publisherId", 0)