🐛 Fix string perm number value node

This commit is contained in:
LittleSheep 2024-11-04 00:53:36 +08:00
parent e1207a8deb
commit 3e68cea0d7

View File

@ -3,6 +3,7 @@ package sec
import (
"fmt"
"reflect"
"strconv"
)
func (v UserInfo) HasPermNode(requiredKey string, requiredValue any) bool {
@ -41,6 +42,11 @@ func comparePermNode(held any, required any) bool {
heldValue := reflect.ValueOf(held)
requiredValue := reflect.ValueOf(required)
if isNumeric(requiredValue) && heldValue.Kind() == reflect.String {
numericValue, _ := strconv.ParseFloat(heldValue.String(), 64)
return toFloat64(requiredValue) >= numericValue
}
switch heldValue.Kind() {
case reflect.String:
if heldValue.String() == requiredValue.String() {