Exemplo n.º 1
0
        public NavigationNode(string action, string controller, string title, object allowedRole = null)
            : this()
        {
            Action     = action;
            Controller = controller;
            Title      = title;

            if (allowedRole != null)
            {
                AllowedRoles.Add(allowedRole);
            }
        }
Exemplo n.º 2
0
 protected void AddRoleClick(object sender, EventArgs e)
 {
     AllowedRoles.DataSource = null;
     foreach (ListItem item in lbRoles.Items)
     {
         if (item.Selected && !_dsRoles.Contains(item.Value))
         {
             _dsRoles.Add(item.Value);
         }
     }
     AllowedRoles.DataSource = _dsRoles;
     AllowedRoles.DataBind();
 }
Exemplo n.º 3
0
 private void LoadSettings()
 {
     if (_dsRoles.Count == 0)
     {
         _allowedRoles = _modcontroler.ModInfo.Settings["EventAdminRoles"] != null
             ? _modcontroler.ModInfo.Settings["EventAdminRoles"].ToString()
             : String.Empty;
         _dsRoles = _allowedRoles.Split(',').ToList();
         AllowedRoles.DataSource = _dsRoles;
         AllowedRoles.DataBind();
         txtRoles.Text = String.Join(Environment.NewLine, _allowedRoles.Split(','));
     }
     rblHolidays.SelectedValue = _modcontroler.ModInfo.Settings["EventShowHolidays"] == null ? "1" : _modcontroler.ModInfo.Settings["EventShowHolidays"].ToString();
 }
        public JsonSerialiseAttribute(params UserRole[] allowedRoles)
        {
            if (allowedRoles.Contains(UserRole.None))
            {
                AllowedRoles = new List <UserRole>();
                return;
            }

            AllowedRoles = allowedRoles.ToList();

            if (!AllowedRoles.Contains(UserRole.Realogy))
            {
                AllowedRoles.Add(UserRole.Realogy);
            }
        }
Exemplo n.º 5
0
        private static void InitializeAllowedEnvironments()
        {
            // Cache the environment and access (true/false) so we don't constantly make an active directory call during view/view model binding.

            AllowedEnvironments = new List <InstallationEnvironment>();

            foreach (var environment in _allEnvironments)
            {
                bool environmentExistsInRoles = AllowedRoles.Exists(
                    r => r.ToString().ToUpperInvariant() == ("Modify" + environment).ToUpperInvariant());

                if (environmentExistsInRoles || UserIsPrestoAdmin)
                {
                    if (!AllowedEnvironments.Exists(x => x.Name == environment.Name))
                    {
                        AllowedEnvironments.Add(environment);
                    }
                }
            }
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // Hide panel if it's restricted to engineers and current
            // user is not an engineer.
            if (IsEngineer && !SessionInfo.Current.User.IsEngineer)
            {
                Visible = false;
                return;
            }

            // Split the list of allowed roles into a list of user roles
            // This is a bit of a hack as we can't pass a collection
            // into the user control, so we pass in a string instead
            // and then convert it into the UserRole enum here.
            var allowedRoles = from role in AllowedRoles.Split(',')
                               select EnumUtils.GetEnumFromValue <UserRole>(role);

            // Make this visible if the current user's role is in the list of allowed roles.
            Visible = allowedRoles.Contains(SessionInfo.Current.User.UserRole);
        }
Exemplo n.º 7
0
    IEnumerable <string> ValidateOptions()
    {
        var errors = new List <string>();

        if (OutputFile == null)
        {
            errors.Add("You must specify an output file.");
        }

        if (VideoDirectory == null)
        {
            errors.Add("You must specify the video directory.");
        }

        if (string.IsNullOrWhiteSpace(WebDirectory))
        {
            errors.Add("You must specify the web directory.");
        }

        if (string.IsNullOrWhiteSpace(CategoryName))
        {
            errors.Add("Please specify the category name.");
        }

        if (Year == 0)
        {
            errors.Add("Please specify the year.");
        }

        if (AllowedRoles == null || !AllowedRoles.Any())
        {
            errors.Add("Please specify at least one role.");
        }

        return(errors);
    }
Exemplo n.º 8
0
 public bool IsInRole(string roleName)
 {
     return(AllowedRoles.Contains(roleName));
 }