✨ Permission check
This commit is contained in:
		@@ -104,7 +104,7 @@ func ConfirmAccount(code string) error {
 | 
			
		||||
		for k, v := range viper.GetStringMap("permissions.verified") {
 | 
			
		||||
			if val, ok := user.PermNodes[k]; !ok {
 | 
			
		||||
				user.PermNodes[k] = v
 | 
			
		||||
			} else if !HasPermNode(val, v) {
 | 
			
		||||
			} else if !ComparePermNode(val, v) {
 | 
			
		||||
				user.PermNodes[k] = v
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,14 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func HasPermNode(held any, required any) bool {
 | 
			
		||||
func HasPermNode(perms map[string]any, requiredKey string, requiredValue any) bool {
 | 
			
		||||
	if heldValue, ok := perms[requiredKey]; ok {
 | 
			
		||||
		return ComparePermNode(heldValue, requiredValue)
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ComparePermNode(held any, required any) bool {
 | 
			
		||||
	heldValue := reflect.ValueOf(held)
 | 
			
		||||
	requiredValue := reflect.ValueOf(required)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user