1234567891011121314151617181920212223242526272829303132 |
- package admin
- import (
- "time"
- "github.com/gofiber/fiber/v2"
- )
- type logoutPage struct {
- configService ConfigService
- }
- func NewLogoutPageHandler(
- configService ConfigService,
- ) fiber.Handler {
- handler := logoutPage{
- configService: configService,
- }
- return handler.handler()
- }
- func (h logoutPage) handler() fiber.Handler {
- return func(fctx *fiber.Ctx) error {
- cookie := new(fiber.Cookie)
- cookie.Name = h.configService.JWTCookie()
- cookie.Expires = time.Now().Add(-1 * time.Second)
- fctx.Cookie(cookie)
- return fctx.Redirect("/admin/login")
- }
- }
|