telco_server/tools/user.go
chenlin 120379a0f9 1.新增权限校验;
2.修改登陆和校验接口(Authenticator、PayloadFunc);
3.对接绿信通接口;
2025-05-19 15:39:05 +08:00

32 lines
723 B
Go

package tools
import (
"fmt"
"github.com/gin-gonic/gin"
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
"time"
)
func ExtractClaims(c *gin.Context) jwt.MapClaims {
claims, exists := c.Get(jwt.JwtPayloadKey)
if !exists {
return make(jwt.MapClaims)
}
return claims.(jwt.MapClaims)
}
func GetCurrentTimeStr() string {
return time.Now().Format("2006-01-02 15:04:05")
}
func GetRoleName(c *gin.Context) string {
data := ExtractClaims(c)
if data["rolekey"] != nil {
fmt.Println("roleKey:", (data["rolekey"]).(string))
return (data["rolekey"]).(string)
}
fmt.Println(GetCurrentTimeStr() + " [WARING] " + c.Request.Method + " " + c.Request.URL.Path + " GetRoleName 缺少rolekey")
return ""
}