exhibition-main/pkg/utils/user.go
2024-01-31 17:04:43 +08:00

20 lines
399 B
Go

package utils
import (
"errors"
"github.com/exhibition-main/internal/model"
"github.com/exhibition-main/internal/msg"
"github.com/exhibition-main/pkg/jwt"
"github.com/gin-gonic/gin"
)
func GetJwtInfo(ctx *gin.Context) (jwtInfo jwt.MyClaims, err error) {
val, ok := ctx.Get(model.CTX_USER_INFO)
if !ok {
err = errors.New(msg.NEED_LOGIN)
return
}
jwtInfo = val.(jwt.MyClaims)
return
}