优化API角色提取

This commit is contained in:
刘祥超
2022-11-22 14:36:06 +08:00
parent 789aeab579
commit 2c06c8932d
2 changed files with 3835 additions and 3834 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -154,8 +154,19 @@ func main() {
roles = append(roles, "node")
}
if strings.Contains(methodSource, ".ValidateUserNode(") {
var hasRoles = false
var wordIndex = strings.Index(methodSource, ".ValidateUserNode(")
if wordIndex > 0 {
if len(methodSource[wordIndex:]) > 100 {
if strings.Contains(methodSource[wordIndex:wordIndex+100], ".ValidateUserNode(ctx, false)") {
hasRoles = true
}
}
if !hasRoles {
roles = append(roles, "user")
}
}
}
if strings.Contains(methodSource, ".ValidateAdmin(") {
roles = append(roles, "admin")
}