2024-06-15 16:55:25 +00:00
|
|
|
package http
|
2024-06-13 08:36:10 +00:00
|
|
|
|
|
|
|
import (
|
2024-07-14 09:44:49 +00:00
|
|
|
"framework_v2/consts"
|
|
|
|
"framework_v2/internal/logic"
|
2024-06-22 11:15:41 +00:00
|
|
|
"framework_v2/internal/providers/helper"
|
2024-07-14 10:14:01 +00:00
|
|
|
"framework_v2/types"
|
2024-06-13 08:36:10 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2024-07-14 10:14:01 +00:00
|
|
|
func RequireJWTIDToken(c *gin.Context) {
|
2024-07-14 09:44:49 +00:00
|
|
|
auth := logic.NewAuthLogic()
|
2024-07-14 10:14:01 +00:00
|
|
|
user, err := auth.GinMiddlewareAuth(types.JWTIDToken, c)
|
2024-06-16 06:00:31 +00:00
|
|
|
|
2024-07-14 09:44:49 +00:00
|
|
|
if err != nil {
|
|
|
|
c.Abort()
|
|
|
|
helper.ResponseError(c, http.StatusUnauthorized, err)
|
|
|
|
return
|
2024-06-13 08:36:10 +00:00
|
|
|
}
|
|
|
|
|
2024-07-14 09:44:49 +00:00
|
|
|
c.Set(consts.AuthMiddlewareKey, user)
|
|
|
|
c.Next()
|
2024-06-13 08:36:10 +00:00
|
|
|
}
|