mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 12:20:27 +08:00
优化从API实现代码中提取角色的方法
This commit is contained in:
@@ -160,7 +160,19 @@ func main() {
|
||||
roles = append(roles, "admin")
|
||||
}
|
||||
if strings.Contains(methodSource, ".ValidateAdminAndUser(") {
|
||||
roles = append(roles, "admin", "user")
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
if strings.Contains(methodSource, ".ValidateNSNode(") {
|
||||
roles = append(roles, "dns")
|
||||
|
||||
Reference in New Issue
Block a user