brunel/handlers/auth/isloggedin.go

16 lines
313 B
Go
Raw Normal View History

2024-07-30 21:36:04 +02:00
package handlers_auth
import (
"brunel/auth"
"github.com/gofiber/fiber/v2"
)
func IsLoggedIn(c *fiber.Ctx) error {
ok, _ := auth.CheckSessionToken(c.Cookies("pt"))
if !ok {
return c.Status(fiber.StatusUnauthorized).SendString("Unauthorized")
}
return c.Status(fiber.StatusOK).SendString("Logged in")
}