public JsonResult DatosSession() { DTOSessionUsuario session = (DTOSessionUsuario)MSession.ReturnSessionObject(); try { session = (DTOSessionUsuario)MSession.ReturnSessionObject(); Response.StatusCode = (int)HttpStatusCode.OK; } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; Response.StatusDescription = ex.Message.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace("\v", "").Replace("\f", "").ToString(); } return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = session }); }
public async Task <ActionResult> Login(DTOLogin user) { try { if (ModelState.IsValid) { if (string.IsNullOrWhiteSpace(user.USU_USERNAME) || string.IsNullOrWhiteSpace(user.USU_PASS)) { return(RedirectToAction("Index", "Login")); } MSession modelo = new MSession(); DTORespuesta respuesta = modelo.ValidaLogin(user); if ((bool)respuesta.Resultado) { DTOSessionUsuario sess = (DTOSessionUsuario)MSession.ReturnSessionObject(); sess.Usuario = await modeloLogin.UpdateUsuario(sess.Usuario); //TODO: Eliminar los archivos asociados al usuario. (Async) mFile = new MFile(); await mFile.eliminarArchivosByLoginAsync(sess.Usuario.USU_LOGIN); return(RedirectToAction("Index", "Home")); } else { Session["ResultadoAccesoLogin"] = respuesta; return(RedirectToAction("Index", "Login")); } } else { return(RedirectToAction("Index", "Login")); } } catch (Exception ex) { return(RedirectToAction("Index", "Login")); } }
public override void OnAuthorization(AuthorizationContext filterContext) { DTOSessionUsuario sess = (DTOSessionUsuario)MSession.ReturnSessionObject(); string controlador = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName; string accion = filterContext.ActionDescriptor.ActionName; if (sess == null) { if (!MSession.isAjaxCall()) { filterContext.Result = new RedirectResult(filterContext.HttpContext.Request.ApplicationPath); } else { filterContext.Result = new HttpUnauthorizedResult(); filterContext.Result = new HttpUnauthorizedResult(); } } else { sess.llamada = controlador + "/" + accion; if (sess.Funcionalidades.FindAll(x => x.FUN_CONTROLLER.ToUpper() == controlador.ToUpper() && x.FUN_ACTION.ToUpper() == accion.ToUpper()).Count == 0) { if (sess.Funcionalidades.FindAll(x => x.FUN_CONTROLLER.ToUpper() == controlador.ToUpper() && (x.FUN_ACTION == "" || accion.ToUpper().Contains("EXCEL") || accion.ToUpper().Contains("CSV") || accion.ToUpper().Contains("PDF") || accion.ToUpper().Contains("DETALLE") || accion.ToUpper().Contains("PNG"))).Count == 0) { if ((controlador.ToUpper() != "MODIFICARACCESO" && controlador.ToUpper() != "IMAGEN")) { if (!MSession.isAjaxCall()) { MSession.FreeSession(); filterContext.Result = new RedirectResult(filterContext.HttpContext.Request.ApplicationPath); } } } } } }