Files
ai-agent/internal/middleware/auth_middleware.go
T
mlogclub 79614b2d07 Refactor import paths to use internal/pkg/httpx/params
- Updated multiple repository and service files to replace imports from "github.com/mlogclub/simple/web/params" with "cs-agent/internal/pkg/httpx/params".
- Adjusted context handling in auth_service and ws_service to use gin.Context instead of iris.Context.
- Ensured consistent usage of HTTP status responses across websocket handlers.
2026-05-23 22:10:20 +08:00

25 lines
424 B
Go

package middleware
import (
"cs-agent/internal/services"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
)
func AuthMiddleware(ctx *gin.Context) {
if !authenticateRequest(ctx) {
return
}
ctx.Next()
}
func authenticateRequest(ctx *gin.Context) bool {
if _, err := services.AuthService.Authenticate(ctx); err != nil {
ctx.JSON(200, web.JsonError(err))
ctx.Abort()
return false
}
return true
}