|
@@ -81,12 +81,8 @@ func ResultJWTWrapper(handle JWTHander, svc *Service) gin.HandlerFunc {
|
|
|
if claims["id"] != nil {
|
|
|
fmt.Printf("%#v\n", claims)
|
|
|
id := claims["id"].(string)
|
|
|
- name := claims["name"].(string)
|
|
|
- phone := claims["phone"].(string)
|
|
|
- parent := claims["parent"].(string)
|
|
|
- state := int32(claims["state"].(float64))
|
|
|
|
|
|
- usr = &JWTUser{ID: id, Phone: phone, Name: name, Parent: parent, State: state}
|
|
|
+ usr = &JWTUser{ID: id}
|
|
|
}
|
|
|
var apis = &ApiSession{
|
|
|
Svc: svc,
|
|
@@ -135,16 +131,8 @@ func ResultJWTWrapperKey(handle JWTHander, svc *Service, keys []string) gin.Hand
|
|
|
|
|
|
if claims["id"] != nil {
|
|
|
id := claims["id"].(string)
|
|
|
- phone := claims["phone"].(string)
|
|
|
- name := claims["name"].(string)
|
|
|
- parent := claims["parent"].(string)
|
|
|
- state := int32(claims["state"].(float64))
|
|
|
- key := ""
|
|
|
- if claims["key"] != nil {
|
|
|
- key = claims["key"].(string)
|
|
|
- }
|
|
|
|
|
|
- usr = &JWTUser{ID: id, Name: name, Phone: phone, Parent: parent, State: state, Key: key}
|
|
|
+ usr = &JWTUser{ID: id}
|
|
|
}
|
|
|
|
|
|
var apis = &ApiSession{
|
|
@@ -152,19 +140,6 @@ func ResultJWTWrapperKey(handle JWTHander, svc *Service, keys []string) gin.Hand
|
|
|
User: usr,
|
|
|
}
|
|
|
|
|
|
- flag := false
|
|
|
- for _, key := range keys {
|
|
|
- if usr.Key == key {
|
|
|
- flag = true
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- if !flag {
|
|
|
- c.JSON(http.StatusForbidden, NewFailResult("您没有权限"))
|
|
|
- c.Abort()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
data, err := handle(c, apis)
|
|
|
|
|
|
if err != nil {
|
|
@@ -332,15 +307,7 @@ func NewErrorWithCode(desc string, code int32) HTTPError {
|
|
|
|
|
|
// JWTUser jwt登录用户
|
|
|
type JWTUser struct {
|
|
|
- ID string `json:"id"`
|
|
|
- Parent string `json:"parent"`
|
|
|
- Name string `json:"name"`
|
|
|
- Phone string `json:"phone"`
|
|
|
- Role string `json:"role"`
|
|
|
- Perms string `json:"perms"`
|
|
|
- State int32 `json:"state"`
|
|
|
- Key string `json:"key"`
|
|
|
- UserType int `json:"userType"`
|
|
|
+ ID string `json:"id"`
|
|
|
}
|
|
|
|
|
|
func UtilQueryMap(c *gin.Context) map[string]interface{} {
|