Ejemplo n.º 1
0
 public override void OnAuthorization(AuthorizationContext filterContext)
 {
     if (SessionPersister.AccountSession == null)
     {
         //si no viene vacio el objeto entramos sin problema
         filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Seguridad", action = "Login" }));
     }
     else
     {
         AccountDomainModel accountModel = new AccountDomainModel();
         AccountViewModel   viewAccount  = SessionPersister.AccountSession;
         AutoMapper.Mapper.Map(viewAccount, accountModel);
         accountModel = IaccountBusiness.ValidarLogin(accountModel);
         AutoMapper.Mapper.Map(accountModel, viewAccount);
         CustomPrincipal customPrincipal = new CustomPrincipal(viewAccount);
         filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Seguridad", action = "Login" }));
     }
     //if (string.IsNullOrEmpty(SessionPersister.Username))
     //    filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Seguridad", action = "Login" }));
     //else
     //{
     //    AccountViewModel am = new AccountViewModel();
     //    CustomPrincipal customPrincipal = new CustomPrincipal(am.Find(SessionPersister.Username));
     //    if (!customPrincipal.IsInRole(Roles))
     //        filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Seguridad", action = "Login" }));
     //}
 }
Ejemplo n.º 2
0
        public ActionResult Login(AccountViewModel accountViewModel)
        {
            usuario.NomUsuario = accountViewModel.Email;
            usuario.Password   = accountViewModel.Password;

            AccountDomainModel accountDomainModel = new AccountDomainModel();

            AutoMapper.Mapper.Map(accountViewModel, accountDomainModel);

            if (IAccountBusiness.ExistUsuario(accountDomainModel))
            {
                accountDomainModel = IAccountBusiness.ValidarLogin(accountDomainModel);


                if (accountDomainModel != null)
                {
                    AccountViewModel viewAccount = new AccountViewModel();
                    AutoMapper.Mapper.Map(accountDomainModel, viewAccount);
                    SessionPersister.AccountSession = viewAccount;
                }
            }
            else
            {
                var res = wsusuariosSoapClient.ConsultaUsuarios(seguridad, usuario);
                //var sigeAlumnp = wsusuariosSoapClient.ConsultaUsuariosAlumno(seguridad, usuario);

                PersonalDomainModel personalDomainModel = new PersonalDomainModel();
                if (res.Nombre_usuario != null && res.Clave != null)
                {
                    _ = res.Nombre == null ? res.Nombre = "..." : res.Nombre = res.Nombre;
                    personalDomainModel.Nombre             = res.Nombre;
                    personalDomainModel.ApellidoPaterno    = res.ApellidoPaterno;
                    personalDomainModel.ApellidoMaterno    = res.ApellidoMaterno;
                    personalDomainModel.AccountDomainModel = new AccountDomainModel {
                        Email = res.Correo_Electronico, Password = usuario.Password, Nombre = usuario.NomUsuario, TipoUsuario = res.TipoUsuario.ToString()
                    };
                    personalDomainModel.strTipoPersonal = res.TipoPersonal.ToString();
                    personalDomainModel.strUniversidad  = res.Universidad;

                    if (IAccountBusiness.AddUsuario(personalDomainModel))
                    {
                        Login(accountViewModel);
                    }
                }
            }
            return(RedirectToAction("Create", "Personal"));
        }
Ejemplo n.º 3
0
        public ActionResult Login(AccountViewModel accountViewModel)
        {
            AccountDomainModel accountDomainModel = new AccountDomainModel();

            AutoMapper.Mapper.Map(accountViewModel, accountDomainModel);

            if (!string.IsNullOrEmpty(accountViewModel.Email) && !string.IsNullOrEmpty(accountViewModel.Password))
            {
                accountDomainModel = IAccountBusiness.ValidarLogin(accountDomainModel);
                if (accountDomainModel != null)
                {
                    AccountViewModel viewAccount = new AccountViewModel();
                    AutoMapper.Mapper.Map(accountDomainModel, viewAccount);
                    SessionPersister.AccountSession = viewAccount;
                    return(RedirectToAction("Create", "Personal"));
                }
                else
                {
                    ViewBag.Validar = Recursos.RecursosSistema.USUARIO_INEXISTENTE;
                }
            }
            return(View());
        }