Better error handling
This commit is contained in:
parent
ee15057b13
commit
227132413a
|
@ -30,7 +30,7 @@ func (h Handlers) AccountDel(c *fiber.Ctx) error {
|
||||||
return c.Status(400).JSON([]ResJSONError{{Error: "Invalid uuid format"}})
|
return c.Status(400).JSON([]ResJSONError{{Error: "Invalid uuid format"}})
|
||||||
}
|
}
|
||||||
|
|
||||||
authErr := h.RequireAdminRole(c)
|
authErr := h.RequireAdminRoleOrAccountID(c, accountID)
|
||||||
if authErr != nil {
|
if authErr != nil {
|
||||||
return c.Status(403).JSON([]ResJSONError{{Error: authErr.Error()}})
|
return c.Status(403).JSON([]ResJSONError{{Error: authErr.Error()}})
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AccountGet godoc
|
// AccountGet godoc
|
||||||
|
@ -22,6 +23,11 @@ import (
|
||||||
func (h Handlers) AccountGet(c *fiber.Ctx) error {
|
func (h Handlers) AccountGet(c *fiber.Ctx) error {
|
||||||
accountID := c.Params("accountID")
|
accountID := c.Params("accountID")
|
||||||
|
|
||||||
|
_, uuidErr := uuid.Parse(accountID)
|
||||||
|
if uuidErr != nil {
|
||||||
|
return c.Status(400).JSON([]ResJSONError{{Error: "Invalid uuid format"}})
|
||||||
|
}
|
||||||
|
|
||||||
authErr := h.RequireAdminRoleOrAccountID(c, accountID)
|
authErr := h.RequireAdminRoleOrAccountID(c, accountID)
|
||||||
if authErr != nil {
|
if authErr != nil {
|
||||||
return c.Status(403).JSON([]ResJSONError{{Error: authErr.Error()}})
|
return c.Status(403).JSON([]ResJSONError{{Error: authErr.Error()}})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user