🐛 Fix publisher api didn't ensure auth cause crash

This commit is contained in:
LittleSheep 2024-11-02 14:05:42 +08:00
parent f14a9be3ec
commit 553a87ab78

View File

@ -2,6 +2,7 @@ package api
import ( import (
"fmt" "fmt"
"git.solsynth.dev/hypernet/interactive/pkg/internal/database" "git.solsynth.dev/hypernet/interactive/pkg/internal/database"
"git.solsynth.dev/hypernet/interactive/pkg/internal/gap" "git.solsynth.dev/hypernet/interactive/pkg/internal/gap"
"git.solsynth.dev/hypernet/interactive/pkg/internal/http/exts" "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 { func listOwnedPublisher(c *fiber.Ctx) error {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(authm.Account) user := c.Locals("user").(authm.Account)
var publishers []models.Publisher var publishers []models.Publisher
@ -100,6 +104,9 @@ func createOrganizationPublisher(c *fiber.Ctx) error {
} }
func editPublisher(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) user := c.Locals("user").(authm.Account)
id, _ := c.ParamsInt("publisherId", 0) id, _ := c.ParamsInt("publisherId", 0)
@ -138,6 +145,9 @@ func editPublisher(c *fiber.Ctx) error {
} }
func deletePublisher(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) user := c.Locals("user").(authm.Account)
id, _ := c.ParamsInt("publisherId", 0) id, _ := c.ParamsInt("publisherId", 0)