/// <summary>
 /// This will Authorize User
 /// </summary>
 public void OnAuthorization(AuthorizationFilterContext context)
 {
     if (context.HttpContext.User.Identity.IsAuthenticated)
     {
         IRoleScreenAccessRepo services = (IRoleScreenAccessRepo)context.HttpContext.RequestServices.GetService(typeof(IRoleScreenAccessRepo));
         var controller = context.RouteData.Values["controller"].ToString();
         var action     = context.RouteData.Values["action"].ToString();
         var result     = services.AllowPermission(controller, action, AccessLevel);
         if (!result.status)
         {
             bool xml = context.HttpContext.Request.Headers.ContainsKey("X-Requested-With");
             context.Result = xml ? new UnauthorizedObjectResult(new Metadata()
             {
                 status = false, data = "Unauthorized (401)"
             }) : new RedirectToActionResult("UnAuth", "Home", null);
         }
         return;
     }
     context.Result = new RedirectToActionResult("index", "login", null);
 }
Beispiel #2
0
 public MenuController(IRoleScreenAccessRepo repo)
 {
     _repo = repo;
 }
Beispiel #3
0
 public MenuAccessController(IRoleScreenAccessRepo accessRepo, IRoleRepo roleRepo)
 {
     _repo     = accessRepo;
     _roleRepo = roleRepo;
 }
Beispiel #4
0
 public UserMenu(IRoleScreenAccessRepo repo)
 {
     _repo = repo;
 }