mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-07 07:10:25 +08:00
优化从API实现代码中提取角色的方法
This commit is contained in:
7549
build/rpc.json
7549
build/rpc.json
File diff suppressed because it is too large
Load Diff
@@ -160,8 +160,20 @@ func main() {
|
|||||||
roles = append(roles, "admin")
|
roles = append(roles, "admin")
|
||||||
}
|
}
|
||||||
if strings.Contains(methodSource, ".ValidateAdminAndUser(") {
|
if strings.Contains(methodSource, ".ValidateAdminAndUser(") {
|
||||||
|
var hasRoles = false
|
||||||
|
var wordIndex = strings.Index(methodSource, ".ValidateAdminAndUser(")
|
||||||
|
if wordIndex > 0 {
|
||||||
|
if len(methodSource[wordIndex:]) > 100 {
|
||||||
|
if strings.Contains(methodSource[wordIndex:wordIndex+100], ".ValidateAdminAndUser(ctx, false)") {
|
||||||
|
roles = append(roles, "admin")
|
||||||
|
hasRoles = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasRoles {
|
||||||
roles = append(roles, "admin", "user")
|
roles = append(roles, "admin", "user")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if strings.Contains(methodSource, ".ValidateNSNode(") {
|
if strings.Contains(methodSource, ".ValidateNSNode(") {
|
||||||
roles = append(roles, "dns")
|
roles = append(roles, "dns")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user