Example #1
0
        /// <summary>
        /// Gets default view.
        /// </summary>
        /// <returns>View result with home view.</returns>
        public ActionResult Index()
        {
            var model = new HomeModel();

            foreach (var route in RoutesProvider.GetRoutes())
            {
                model.Routes.Add(route);
            }

            return(this.View("~/Views/Home/Home.cshtml", model));
        }
Example #2
0
        public IHttpActionResult Get()
        {
            if (User.Identity.IsAuthenticated)
            {
                string id = User.Identity.GetUserId();
                ApplicationUserManager userManager = Request.GetOwinContext().GetUserManager <ApplicationUserManager>();
                IList <string>         roles       = userManager.GetRoles(id);
                string role = roles.FirstOrDefault();
                if (!string.IsNullOrWhiteSpace(role))
                {
                    return(Ok(RoutesProvider.GetRoutesByRole(role)));
                }
            }
            List <string> list = RoutesProvider.GetPublicRoutes();

            return(Ok(list));
        }
Example #3
0
        private static void AddResources(SecurityDbContext context)
        {
            List <string> names = RoutesProvider.GetAllRoutes();

            foreach (var name in names)
            {
                var resource = context.Resources.FirstOrDefault(x => x.Name == name);
                if (resource == null)
                {
                    var r = new ApplicationResource
                    {
                        IsPublic = false,
                        Name     = name,
                    };
                    context.Resources.Add(r);
                }
            }
        }