コード例 #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);
            }
        }
コード例 #2
0
        public static PropertyAllowed GetPropertyAllowed(this PropertyRoute route)
        {
            if (!AuthLogic.IsEnabled || ExecutionMode.InGlobal)
            {
                return(PropertyAllowed.Write);
            }

            route = route.SimplifyToPropertyOrRoot();

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

            return(cache.GetAllowed(RoleEntity.Current, route));
        }