Esempio n. 1
0
        static MapColorProvider[] GetMapColors()
        {
            if (!BasicPermission.AdminRules.IsAuthorized())
            {
                return(new MapColorProvider[0]);
            }

            var roleRules = AuthLogic.RolesInOrder().ToDictionary(r => r,
                                                                  r => TypeAuthLogic.GetTypeRules(r).Rules.ToDictionary(a => a.Resource.CleanName, a => a.Allowed));

            return(roleRules.Keys.Select((r, i) => new MapColorProvider
            {
                Name = "role-" + r.Key(),
                NiceName = "Role - " + r.ToString(),
                AddExtra = t =>
                {
                    TypeAllowedAndConditions tac = roleRules[r].TryGetC(t.typeName);

                    if (tac == null)
                    {
                        return;
                    }

                    t.extra["role-" + r.Key() + "-ui"] = GetName(ToStringList(tac, userInterface: true));
                    t.extra["role-" + r.Key() + "-db"] = GetName(ToStringList(tac, userInterface: false));
                    t.extra["role-" + r.Key() + "-tooltip"] = ToString(tac.Fallback) + "\n" + (tac.Conditions.IsNullOrEmpty() ? null :
                                                                                               tac.Conditions.ToString(a => a.TypeCondition.NiceToString() + ": " + ToString(a.Allowed), "\n") + "\n");
                },
                Order = 10,
            }).ToArray());
        }
Esempio n. 2
0
        static MapColorProvider[] GetMapColors()
        {
            if (!BasicPermission.AdminRules.IsAuthorized())
            {
                return(new MapColorProvider[0]);
            }

            var roleRules = AuthLogic.RolesInOrder().ToDictionary(r => r,
                                                                  r => TypeAuthLogic.GetTypeRules(r).Rules.ToDictionary(a => Navigator.ResolveWebTypeName(a.Resource.ToType()), a => a.Allowed));

            return(roleRules.Keys.Select((r, i) => new MapColorProvider
            {
                Name = "role-" + r.Key(),
                NiceName = "Role - " + r.ToString(),
                GetJsProvider = ColorModule["authAdminColor"](MapClient.NodesConstant, "role-" + r.Key()),
                AddExtra = t =>
                {
                    TypeAllowedAndConditions tac = roleRules[r].TryGetC(t.webTypeName);

                    if (tac == null)
                    {
                        return;
                    }

                    t.extra["role-" + r.Key() + "-ui"] = GetName(ToStringList(tac, userInterface: true));
                    t.extra["role-" + r.Key() + "-db"] = GetName(ToStringList(tac, userInterface: false));
                    t.extra["role-" + r.Key() + "-tooltip"] = ToString(tac.Fallback) + "\n" + (tac.Conditions.IsNullOrEmpty() ? null :
                                                                                               tac.Conditions.ToString(a => a.TypeCondition.NiceToString() + ": " + ToString(a.Allowed), "\n") + "\n");
                },
                Defs = i == 0 ? GetAllGradients(roleRules) : null,
                Order = 10,
            }).ToArray());
        }
        public TypeRulePack GetTypeRules(string roleId)
        {
            BasicPermission.AdminRules.AssertAuthorized();
            var rules = TypeAuthLogic.GetTypeRules(Lite.ParsePrimaryKey <RoleEntity>(roleId).FillToString());

            CleanChanges(rules);
            return(rules);
        }
Esempio n. 4
0
        public ActionResult Types(FormCollection form)
        {
            Lite <RoleEntity> role = this.ExtractLite <RoleEntity>("Role");

            var prp = TypeAuthLogic.GetTypeRules(role).ApplyChanges(this, "");;

            TypeAuthLogic.SetTypeRules(prp.Value);

            return(RedirectToAction("Types", new { role = role.Id }));
        }
Esempio n. 5
0
 public ViewResult Types(Lite <RoleEntity> role)
 {
     return(Navigator.NormalPage(this, TypeAuthLogic.GetTypeRules(role.FillToString())));
 }