This commit is contained in:
aozhiwei 2024-08-04 10:56:15 +08:00
parent c03cc919ef
commit bbb1012d13

View File

@ -64,14 +64,14 @@ func (this *PermissionTable) CheckAPIPermission(account string, cmd string) bool
return false return false
} }
func (this *PermissionTable) GetUIPermission(account string) string { func (this *PermissionTable) GetUIPermission(accountAddress string) string {
per, exist := this.userHash.Load(account) u, exist := this.userHash.Load(strings.ToLower(accountAddress))
if !exist { if !exist {
return "{}" return "{}"
} }
kvlist := map[string]bool{} kvlist := map[string]bool{}
(*per).ui.Range(func(k string, v bool) bool { (*u).ui.Range(func(k string, v bool) bool {
kvlist[k] = v kvlist[k] = v
return true return true
}) })
@ -197,10 +197,28 @@ func (this *PermissionTable) genUserPermission(u *user) {
}) })
{ {
for _, val := range u.specApi { for _, val := range u.specApi {
u.api.Store(val, true) if len(val) <= 0 {
continue
}
if val[0] == '-' {
if len(val) > 1 {
u.api.Store(val[1:], false)
}
} else {
u.api.Store(val, true)
}
} }
for _, val := range u.specUi { for _, val := range u.specUi {
u.ui.Store(val, true) if len(val) <= 0 {
continue
}
if val[0] == '-' {
if len(val) > 1 {
u.ui.Store(val[1:], false)
}
} else {
u.ui.Store(val, true)
}
} }
} }
} }