Exemplo n.º 1
0
        public static TypeRulePack GetTypeRules(Lite <RoleEntity> roleLite)
        {
            var result = new TypeRulePack {
                Role = roleLite
            };
            Schema s = Schema.Current;

            cache.GetRules(result, TypeLogic.TypeToEntity.Where(t => !t.Key.IsEnumEntity() && s.IsAllowed(t.Key, false) == null).Select(a => a.Value));

            foreach (TypeAllowedRule r in result.Rules)
            {
                Type type = TypeLogic.EntityToType[r.Resource];

                if (OperationAuthLogic.IsStarted)
                {
                    r.Operations = OperationAuthLogic.GetAllowedThumbnail(roleLite, type);
                }

                if (PropertyAuthLogic.IsStarted)
                {
                    r.Properties = PropertyAuthLogic.GetAllowedThumbnail(roleLite, type);
                }

                if (QueryAuthLogic.IsStarted)
                {
                    r.Queries = QueryAuthLogic.GetAllowedThumbnail(roleLite, type);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            TypeRulePack trp = (TypeRulePack)DataContext;

            trp.Rules = ((List <NamespaceNode>)treeView.ItemsSource).SelectMany(a => a.SubNodes).Select(a => a.ToRule()).ToMList();

            Server.Execute((ITypeAuthServer s) => s.SetTypesRules(trp));
            Load();
        }
Exemplo n.º 3
0
        private void Load()
        {
            this.Title = AuthMessage._0RulesFor1.NiceToString().FormatWith(typeof(TypeEntity).NiceName(), Role);

            TypeRulePack trp = Server.Return((ITypeAuthServer s) => s.GetTypesRules(Role));

            DataContext = trp;

            treeView.ItemsSource = (from r in trp.Rules
                                    group r by r.Resource.Namespace into g
                                    orderby g.Key
                                    select new NamespaceNode
            {
                Name = g.Key,
                SubNodes = g.OrderBy(a => a.Resource.ClassName).Select(a => new TypeRuleBuilder(a)).ToList()
            }).ToList();
        }
Exemplo n.º 4
0
 public static void SetTypeRules(TypeRulePack rules)
 {
     cache.SetRules(rules);
 }
Exemplo n.º 5
0
 public void SetTypesRules(TypeRulePack rules)
 {
     Execute(MethodInfo.GetCurrentMethod(),
       () => TypeAuthLogic.SetTypeRules(rules));
 }
Exemplo n.º 6
0
 public void SetTypeRules([Required, FromBody] TypeRulePack rules)
 {
     BasicPermission.AdminRules.AssertAuthorized();
     TypeAuthLogic.SetTypeRules(rules);
 }
Exemplo n.º 7
0
 public void SetTypeRules(TypeRulePack rules)
 {
     BasicPermission.AdminRules.AssertAuthorized();
     TypeAuthLogic.SetTypeRules(rules);
 }
Exemplo n.º 8
0
 public void SetTypeRules(TypeRulePack rules)
 {
     BasicPermission.AdminRules.AssertAuthorized();
     TypeAuthLogic.SetTypeRules(rules);
 }