package utils

import (
	"errors"
	"github.com/gin-gonic/gin"
	"testData/model"
)

func JWTGetUser(c *gin.Context) (*model.User, error) {
	claims, exists := c.Get("claims")
	if !exists {
		return nil, errors.New("token中未找到claims")
	}
	useUser, ok := claims.(*model.User)
	if !ok {
		return nil, errors.New("token中断言User失败")
	}
	return useUser, nil
}
