From 17353614412b373c7b014b6a8fa60304aa3d4135 Mon Sep 17 00:00:00 2001 From: nilo Date: Sun, 24 Nov 2024 16:02:01 -0300 Subject: [PATCH] bugfix --- controllers/authController.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/authController.go b/controllers/authController.go index 52005b1..9b58dcf 100644 --- a/controllers/authController.go +++ b/controllers/authController.go @@ -132,7 +132,11 @@ func AddUser(c *fiber.Ctx) error { // MARK: GetOwnUser func GetOwnUser(c *fiber.Ctx) error { - user := c.Locals("user").(models.User) + user, ok := c.Locals("user").(models.User) + + if !ok { + return fiber.NewError(fiber.StatusUnauthorized, "Unauthorized: User is not admin") + } return c.JSON(user) }