public static bool IsAllowed(Security.Role[] roles) { if (IsAuthenticated()) { AuthenticatedUser user = GetAuthenticatedUser(); return (roles.Contains(user.Role) || user.Role == Security.Role.Administrator); } return false; }
public static SelectList List(string selected, Security.Role role) { List<SelectListItem> list = new List<SelectListItem>(); foreach (Engine.Template.Id item in Enum.GetValues(typeof(Engine.Template.Id))) { if (role != Security.Role.Super_Administrator) { if (item == Engine.Template.Id.Static_Page) { list.Add(new SelectListItem { Text = Enum.GetName(typeof(Engine.Template.Id), item).Replace('_', ' '), Value = item.ToString(), Selected = ((!string.IsNullOrEmpty(selected)) ? ((item.ToString().Equals(selected)) ? true : false) : false) }); } } else { list.Add(new SelectListItem { Text = Enum.GetName(typeof(Engine.Template.Id), item).Replace('_', ' '), Value = item.ToString(), Selected = ((!string.IsNullOrEmpty(selected)) ? ((item.ToString().Equals(selected)) ? true : false) : false) }); } } return new SelectList(list, "Value", "Text", selected); }
public static SelectList Roles(IEnumerable<Security.Role> selected, Security.Role authenticatedRole) { List<SelectListItem> list = new List<SelectListItem>(); List<int> selectedRoles = new List<int>(); bool start = false; foreach (Security.Role item in Enum.GetValues(typeof(Security.Role))) { if (!start) { if (item == authenticatedRole) { start = true; } } if (start) { list.Add(new SelectListItem { Text = Enum.GetName(typeof(Security.Role), item).Replace('_', ' '), Value = item.ToString() }); } } return new SelectList(list, "Value", "Text", selectedRoles); }
private AuthenticatedUser(int personID, string name, Security.Role secRole) { ID = personID; Name = name; Role = secRole; }