Beispiel #1
0
        public ActionResult GetAllList_Module([DataSourceRequest] DataSourceRequest request)
        {
            // if (!FachadaSeguridad.Autorizado(HttpContext.User.Identity.Name, "/Usuario/Index", AuditoriaAccion.Lectura))
            //     throw new Exception("Sin acceso");

            var ls = FacadeModule.GetAll();

            return(Json(ls.ToDataSourceResult(request), JsonRequestBehavior.DenyGet));
        }
Beispiel #2
0
        public override void OnAuthorization(AuthorizationContext filterContext)


        {
            //filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

            var UserToken = filterContext.RequestContext.HttpContext.Request.Cookies["ServiPlus"];

            if (UserToken == null)

            {
                filterContext.Result = new RedirectResult("/Security/Index");
            }

            else
            {
                var usrData = FacadeUsers.GetUserByToken(UserToken.Values["TokenUser"]);

                var ruta = filterContext.HttpContext.Request.Url.AbsolutePath;
                if (ruta == "/")
                {
                    ruta = "/Home/Index";
                }

                var access = (from a in FacadeModule.GetAll().Where(p => p.URL == ruta)
                              join b in FacadePermission.GetAll(usrData.ProfileID) on a.ModuleID equals b.ModuleID
                              select new ModelViewPermission
                {
                    ModuleID = a.ModuleID,
                    ProfileID = b.ProfileID,
                    Module = a.Module,
                    URL = a.URL,
                    Access = b.Access
                }).First();

                if (!access.Access)
                {
                    filterContext.Result = new RedirectResult("/Security/Error");
                }
                else
                {
                    if (usrData == null)
                    {
                        filterContext.Result = new RedirectResult("/Security/Index");
                    }
                    filterContext.Controller.ViewBag.Profile = FacadeProfile.GetAll().Where(p => p.ProfileID == usrData.ProfileID).Single().Profile;
                    filterContext.Controller.ViewBag.User    = usrData.Name;
                    filterContext.Controller.ViewBag.Module  = "Global";
                }

                //if (usrData == null) filterContext.Result = new RedirectResult("/Security/Index");
                //filterContext.Controller.ViewBag.Profile = FacadeProfile.GetAll().Where(p => p.ProfileID == usrData.ProfileID).Single().Profile;
                //filterContext.Controller.ViewBag.User = usrData.Name;
                //filterContext.Controller.ViewBag.Module = "Global";
            }
        }
Beispiel #3
0
 public JsonResult saveModule(ModelViewModule model)
 {
     if (model.ModuleID == 0)
     {
         //if (!FachadaSeguridad.Autorizado(HttpContext.User.Identity.Name, "/Usuario/Index", AuditoriaAccion.Agregar))
         //    return Json("Unauthorized");
         FacadeModule.Insert(model);
     }
     else
     {
         //if (!FachadaSeguridad.Autorizado(HttpContext.User.Identity.Name, "/Usuario/Index", AuditoriaAccion.Actualizar))
         //    return Json("Unauthorized");
         FacadeModule.Update(model);
     }
     return(Json("{ Result: 'Success'}"));
 }
Beispiel #4
0
        public ActionResult SetStatus_Permission(string ModuleIDs)
        {
            try
            {
                //var user = (User)Session["Usuario"];

                List <int> arr = ModuleIDs.Split(',').Select(Int32.Parse).ToList();
                FacadeModule.SetStatus(arr);

                //FacadeAudit.RegisterEntity("/ConfigPromotionTypes/Index", TransactionType.STATUS, "", "", user.IdUser);

                return(Json("Solicitud procesada con éxito", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                //if (ex.GetType().Name == "Duplicate_Exception") throw ex;
                //if (ex.GetType().Name == "CustomExceptions") throw ex;
                //throw new CustomExceptions(ex, CustomExceptions.ErrorCodes.E_C_Generic);
                throw ex;
            }
        }