🐛 Fix string perm number value node
This commit is contained in:
parent
e1207a8deb
commit
3e68cea0d7
@ -3,6 +3,7 @@ package sec
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v UserInfo) HasPermNode(requiredKey string, requiredValue any) bool {
|
func (v UserInfo) HasPermNode(requiredKey string, requiredValue any) bool {
|
||||||
@ -41,6 +42,11 @@ func comparePermNode(held any, required any) bool {
|
|||||||
heldValue := reflect.ValueOf(held)
|
heldValue := reflect.ValueOf(held)
|
||||||
requiredValue := reflect.ValueOf(required)
|
requiredValue := reflect.ValueOf(required)
|
||||||
|
|
||||||
|
if isNumeric(requiredValue) && heldValue.Kind() == reflect.String {
|
||||||
|
numericValue, _ := strconv.ParseFloat(heldValue.String(), 64)
|
||||||
|
return toFloat64(requiredValue) >= numericValue
|
||||||
|
}
|
||||||
|
|
||||||
switch heldValue.Kind() {
|
switch heldValue.Kind() {
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
if heldValue.String() == requiredValue.String() {
|
if heldValue.String() == requiredValue.String() {
|
||||||
|
Loading…
Reference in New Issue
Block a user