Exemplo n.º 1
0
        protected bool IsAllowed(Action fullAction, Role role)
        {
            var parts = fullAction.Link.Split('/');

            var controller = _Container.Resolve <IController>(parts[0] + "controller");
            var action     = controller.GetType().GetMethods().Where(m => m.Name == parts[1] && !IsPost(m) && m.GetParameters().Length == 0).FirstOrDefault();

            var attribute = Attribute.GetCustomAttribute(action, typeof(AllowAttribute), false) as AllowAttribute;

            return(attribute == null || Roles.Provider.IsUserInRole(HttpContext.Current.User.Identity.Name, attribute.Role.ToString()));
        }
Exemplo n.º 2
0
        protected bool IsAllowed(Action fullAction, IEnumerable <string> roles)
        {
            var parts = fullAction.Link.Split('/');

            var controller = _Container.Resolve <IController>(parts[0] + "controller");
            var action     = controller.GetType().GetMethods().Where(m => m.Name == parts[1] && !IsPost(m) && m.GetParameters().Length == 0).FirstOrDefault();

            var attribute = Attribute.GetCustomAttribute(action, typeof(AllowAttribute), false) as AllowAttribute;

            return(attribute == null || roles.Contains(attribute.Role.ToString()));
        }
Exemplo n.º 3
0
        protected bool IsAllowed(Action fullAction, IEnumerable<string> roles)
        {
            var parts = fullAction.Link.Split('/');

            var controller = _Container.Resolve<IController>(parts[0] + "controller");
            var action = controller.GetType().GetMethods().Where(m => m.Name == parts[1] && !IsPost(m) && m.GetParameters().Length == 0).FirstOrDefault();

            var attribute = Attribute.GetCustomAttribute(action, typeof(AllowAttribute), false) as AllowAttribute;

            return attribute == null || roles.Contains(attribute.Role.ToString());
        }
Exemplo n.º 4
0
        protected bool IsAllowed(Action fullAction, Role role)
        {
            var parts = fullAction.Link.Split('/');

            var controller = _Container.Resolve<IController>(parts[0] + "controller");
            var action = controller.GetType().GetMethods().Where(m => m.Name == parts[1] && !IsPost(m) && m.GetParameters().Length == 0).FirstOrDefault();

            var attribute = Attribute.GetCustomAttribute(action, typeof(AllowAttribute), false) as AllowAttribute;

            return attribute == null || Roles.Provider.IsUserInRole(HttpContext.Current.User.Identity.Name, attribute.Role.ToString());
        }