Skip to content

Commit

Permalink
added isadmin middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirari04 committed Jan 3, 2024
1 parent 6ece253 commit 5fa0ea6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions middlewares/IsAdmin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package middlewares

import (
"github.com/gofiber/fiber/v2"
)

func IsAdmin(c *fiber.Ctx) error {
isAdmin, ok := c.Locals("Admin").(bool)
if !ok {
return c.SendStatus(fiber.StatusInternalServerError)
}
if !isAdmin {
return c.Status(fiber.StatusForbidden).SendString("Not Permitted")
}
return c.Next()
}

0 comments on commit 5fa0ea6

Please sign in to comment.