|
@@ -66,64 +66,66 @@ func (this *MobileBaseAPIAuthController) Prepare() {
|
66
|
66
|
// this.StopRun()
|
67
|
67
|
// }
|
68
|
68
|
//}
|
|
69
|
+ if !adminUserInfo.AdminUser.IsSuperAdmin || adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
|
69
|
70
|
|
70
|
|
- if this.Ctx.Request.Header.Get("Permission") == "1" {
|
71
|
|
- isPermission := false
|
72
|
|
- adminUserInfo := this.GetMobileAdminUserInfo()
|
73
|
|
- //该机构下该用户有多少个
|
74
|
|
- role, _ := service.GetUserAllRole(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id)
|
75
|
|
- var roles []string
|
76
|
|
- if len(role.RoleIds) <= 0 { //该用户没有设置角色
|
|
71
|
+ if this.Ctx.Request.Header.Get("Permission") == "1" {
|
|
72
|
+ isPermission := false
|
|
73
|
+ adminUserInfo := this.GetMobileAdminUserInfo()
|
|
74
|
+ //该机构下该用户有多少个
|
|
75
|
+ role, _ := service.GetUserAllRole(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id)
|
|
76
|
+ var roles []string
|
|
77
|
+ if len(role.RoleIds) <= 0 { //该用户没有设置角色
|
77
|
78
|
|
78
|
|
- } else {
|
79
|
|
- roles = strings.Split(role.RoleIds, ",")
|
80
|
|
- }
|
81
|
|
- fmt.Println(roles)
|
82
|
|
-
|
83
|
|
- //获取该用户下所有角色的权限总集
|
84
|
|
- var userRolePurviews string
|
85
|
|
- var userRolePurviewsArr []string
|
86
|
|
- for _, item := range roles {
|
87
|
|
- role_id, _ := strconv.ParseInt(item, 10, 64)
|
88
|
|
- purviews, _ := service.GetRoleFuncPurviewIds(role_id)
|
89
|
|
- if len(userRolePurviews) == 0 {
|
90
|
|
- userRolePurviews = purviews
|
91
|
79
|
} else {
|
92
|
|
- userRolePurviews = userRolePurviews + "," + purviews
|
|
80
|
+ roles = strings.Split(role.RoleIds, ",")
|
93
|
81
|
}
|
94
|
|
- }
|
95
|
|
- //该用户所拥有角色的权限的总集
|
96
|
|
- userRolePurviewsArr = RemoveRepeatedPurviewElement(strings.Split(userRolePurviews, ","))
|
97
|
|
- fmt.Println(userRolePurviewsArr)
|
98
|
|
- //系统所记录的权限列表
|
99
|
|
- allPermission, _ := service.GetAllFunctionPurview()
|
100
|
|
-
|
101
|
|
- for _, item := range allPermission {
|
102
|
|
- fmt.Println(strings.Split(item.Urlfor, ",")[0])
|
103
|
|
- fmt.Println(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
|
104
|
|
-
|
105
|
|
- //判断当前路由是否在权限路由列表里面
|
106
|
|
- if strings.Split(item.Urlfor, ",")[0] == strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode") {
|
107
|
|
-
|
108
|
|
- //获取该角色的所有权限
|
109
|
|
- for _, items := range userRolePurviewsArr {
|
110
|
|
- id, _ := strconv.ParseInt(items, 10, 64)
|
111
|
|
- fmt.Println(id)
|
112
|
|
- fmt.Println(item.ID)
|
113
|
|
-
|
114
|
|
- if id == item.ID {
|
115
|
|
- isPermission = true
|
116
|
|
- }
|
|
82
|
+ fmt.Println(roles)
|
|
83
|
+
|
|
84
|
+ //获取该用户下所有角色的权限总集
|
|
85
|
+ var userRolePurviews string
|
|
86
|
+ var userRolePurviewsArr []string
|
|
87
|
+ for _, item := range roles {
|
|
88
|
+ role_id, _ := strconv.ParseInt(item, 10, 64)
|
|
89
|
+ purviews, _ := service.GetRoleFuncPurviewIds(role_id)
|
|
90
|
+ if len(userRolePurviews) == 0 {
|
|
91
|
+ userRolePurviews = purviews
|
|
92
|
+ } else {
|
|
93
|
+ userRolePurviews = userRolePurviews + "," + purviews
|
117
|
94
|
}
|
118
|
|
- if !isPermission {
|
119
|
|
- msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
|
120
|
|
- json := make(map[string]interface{})
|
121
|
|
- json["msg"] = msg
|
122
|
|
- json["code"] = 0
|
123
|
|
- json["state"] = 0
|
124
|
|
- this.Data["json"] = json
|
125
|
|
- this.ServeJSON()
|
126
|
|
- this.StopRun()
|
|
95
|
+ }
|
|
96
|
+ //该用户所拥有角色的权限的总集
|
|
97
|
+ userRolePurviewsArr = RemoveRepeatedPurviewElement(strings.Split(userRolePurviews, ","))
|
|
98
|
+ fmt.Println(userRolePurviewsArr)
|
|
99
|
+ //系统所记录的权限列表
|
|
100
|
+ allPermission, _ := service.GetAllFunctionPurview()
|
|
101
|
+
|
|
102
|
+ for _, item := range allPermission {
|
|
103
|
+ fmt.Println(strings.Split(item.Urlfor, ",")[0])
|
|
104
|
+ fmt.Println(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
|
|
105
|
+
|
|
106
|
+ //判断当前路由是否在权限路由列表里面
|
|
107
|
+ if strings.Split(item.Urlfor, ",")[0] == strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode") {
|
|
108
|
+
|
|
109
|
+ //获取该角色的所有权限
|
|
110
|
+ for _, items := range userRolePurviewsArr {
|
|
111
|
+ id, _ := strconv.ParseInt(items, 10, 64)
|
|
112
|
+ fmt.Println(id)
|
|
113
|
+ fmt.Println(item.ID)
|
|
114
|
+
|
|
115
|
+ if id == item.ID {
|
|
116
|
+ isPermission = true
|
|
117
|
+ }
|
|
118
|
+ }
|
|
119
|
+ if !isPermission {
|
|
120
|
+ msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
|
|
121
|
+ json := make(map[string]interface{})
|
|
122
|
+ json["msg"] = msg
|
|
123
|
+ json["code"] = 0
|
|
124
|
+ json["state"] = 0
|
|
125
|
+ this.Data["json"] = json
|
|
126
|
+ this.ServeJSON()
|
|
127
|
+ this.StopRun()
|
|
128
|
+ }
|
127
|
129
|
}
|
128
|
130
|
}
|
129
|
131
|
}
|