rag/internal/middleware/http/jwt.go
2024-07-14 18:14:01 +08:00

25 lines
463 B
Go

package http
import (
"framework_v2/consts"
"framework_v2/internal/logic"
"framework_v2/internal/providers/helper"
"framework_v2/types"
"github.com/gin-gonic/gin"
"net/http"
)
func RequireJWTIDToken(c *gin.Context) {
auth := logic.NewAuthLogic()
user, err := auth.GinMiddlewareAuth(types.JWTIDToken, c)
if err != nil {
c.Abort()
helper.ResponseError(c, http.StatusUnauthorized, err)
return
}
c.Set(consts.AuthMiddlewareKey, user)
c.Next()
}