Example #1
0
        public static string?GetAllowedFor(this PropertyRoute route, PropertyAllowed requested)
        {
            if (!AuthLogic.IsEnabled || ExecutionMode.InGlobal)
            {
                return(null);
            }

            route = route.SimplifyToPropertyOrRoot();

            if (route.PropertyRouteType == PropertyRouteType.Root || route.IsToStringProperty())
            {
                PropertyAllowed paType = TypeAuthLogic.GetAllowed(route.RootType).MaxUI().ToPropertyAllowed();
                if (paType < requested)
                {
                    return("Type {0} is set to {1} for {2}".FormatWith(route.RootType.NiceName(), paType, RoleEntity.Current));
                }

                return(null);
            }
            else
            {
                PropertyAllowed paProperty = cache.GetAllowed(RoleEntity.Current, route);

                if (paProperty < requested)
                {
                    return("Property {0} is set to {1} for {2}".FormatWith(route, paProperty, RoleEntity.Current));
                }

                return(null);
            }
        }
Example #2
0
        public static string GetAllowedFor(this PropertyRoute route, PropertyAllowed requested)
        {
            if (route.PropertyRouteType == PropertyRouteType.MListItems || route.PropertyRouteType == PropertyRouteType.LiteEntity)
            {
                return(GetAllowedFor(route.Parent, requested));
            }

            if (!typeof(Entity).IsAssignableFrom(route.RootType))
            {
                return(null);
            }

            if (route.PropertyRouteType == PropertyRouteType.Root || route.IsToStringProperty())
            {
                var typeAllowed = TypeAuthClient.GetAllowed(route.RootType).MaxUI().ToPropertyAllowed();
                if (typeAllowed < requested)
                {
                    return("Type {0} is set to {1} for {2}".FormatWith(route.RootType.NiceName(), typeAllowed, RoleEntity.Current));
                }

                return(null);
            }

            var propAllowed = GetPropertyAllowed(route);

            if (propAllowed < requested)
            {
                var typeAllowed = TypeAuthClient.GetAllowed(route.RootType).MaxUI().ToPropertyAllowed();

                if (typeAllowed < requested)
                {
                    return("Type {0} is set to {1} for {2}".FormatWith(route.RootType.NiceName(), typeAllowed, RoleEntity.Current));
                }

                return("Property {0} is set to {1} for {2}".FormatWith(route, propAllowed, RoleEntity.Current));
            }

            return(null);
        }
Example #3
0
        public static PropertyAllowed GetPropertyAllowed(this PropertyRoute route)
        {
            while (route.PropertyRouteType == PropertyRouteType.MListItems || route.PropertyRouteType == PropertyRouteType.LiteEntity)
            {
                route = route.Parent;
            }

            if (!typeof(Entity).IsAssignableFrom(route.RootType))
            {
                return(PropertyAllowed.Modify);
            }

            if (route.PropertyRouteType == PropertyRouteType.Root || route.IsToStringProperty())
            {
                return(TypeAuthClient.GetAllowed(route.RootType).MaxUI().ToPropertyAllowed());
            }

            var propAllowed = propertyRules.GetAllowed(route);

            var typeAllowed = TypeAuthClient.GetAllowed(route.RootType).MaxUI().ToPropertyAllowed();

            return(propAllowed < typeAllowed ? propAllowed : typeAllowed);
        }