wip: session auth middleware

This commit is contained in:
2025-06-05 06:26:11 +01:00
parent af8323cdb0
commit 627633ea29
10 changed files with 96 additions and 29 deletions
+21
View File
@@ -0,0 +1,21 @@
package api
import (
"net/http"
"github.com/labstack/echo-contrib/session"
"github.com/labstack/echo/v4"
)
func SessionMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
return func(context echo.Context) error {
sess, err := session.Get("session", context)
if sess == nil || err != nil {
return context.String(http.StatusBadRequest, "User not authenticated!")
}
context.Set("id", sess.Values["id"])
return next(context)
}
}