2025-01-27 03:23:54 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
2025-01-31 22:42:32 +00:00
|
|
|
"errors"
|
2025-01-27 03:23:54 +00:00
|
|
|
"github.com/gofiber/fiber/v2"
|
2025-01-27 10:48:40 +00:00
|
|
|
"lmika.dev/lmika/hugo-cms/models"
|
2025-01-27 03:23:54 +00:00
|
|
|
)
|
|
|
|
|
2025-01-31 22:42:32 +00:00
|
|
|
func GetUser(c *fiber.Ctx) models.User {
|
|
|
|
u, ok := c.Locals("user").(models.User)
|
|
|
|
if !ok {
|
|
|
|
panic(errors.New("user not found in context"))
|
|
|
|
}
|
|
|
|
return u
|
|
|
|
}
|
2025-01-27 03:23:54 +00:00
|
|
|
|
|
|
|
func GetSite(c *fiber.Ctx) models.Site {
|
2025-01-31 22:42:32 +00:00
|
|
|
s, ok := c.Locals("site").(models.Site)
|
|
|
|
if !ok {
|
|
|
|
panic(errors.New("no site in context"))
|
|
|
|
}
|
|
|
|
return s
|
2025-01-27 03:23:54 +00:00
|
|
|
}
|