示例#1
0
        public ActionResult Index(string pin)
        {
            var user = SeguridadDelegate.UsuarioTemporal;

            if ((user.RequiereOtp && !user.OtpActivo) &&
                string.IsNullOrEmpty(pin))
            {
                var model = SeguridadDelegate.GenerarCodigo(user.CodUsuario);
                SeguridadDelegate.UsuarioTemporal = user;
                ViewBag.Action = "Index";
                return(PartialView("_CrearClaveAut", model));
            }
            if (!string.IsNullOrEmpty(pin))
            {
                var isCorrectPIN = SeguridadDelegate.ValidarPinAutenticacion(user.CodUsuario, pin);
                if (!isCorrectPIN)
                {
                    throw new ControllerException(RecMensajes.Msj_PinInvalido);
                }
            }
            var paises = GeneralesDelegate.ConsultarPaises();

            ViewBag.ListaPaises = paises;
            var idiomas = GeneralesDelegate.ConsultarIdiomas();

            ViewBag.ListaIdiomas = idiomas;
            var preguntas = MembresiaDelegate.ObtenerPreguntas();

            ViewBag.CollectionPreguntas = preguntas;
            return(PartialView("_Registro", new ModUsuarioRegistro
            {
                ListaPreguntas = new List <ModPreguntaUsuario> {
                    new ModPreguntaUsuario(), new ModPreguntaUsuario(),
                    new ModPreguntaUsuario(), new ModPreguntaUsuario(),
                    new ModPreguntaUsuario()
                }
            }));
        }
示例#2
0
        public ActionResult ProcesaRespuestaAuth(bool?changePassword, bool?isEmbedded)
        {
            var user = SeguridadDelegate.UsuarioTemporal;

            if (changePassword.HasValue && changePassword.Value)
            {
                return(PartialView("_LogInRenew", new ModCambioContrasena
                {
                    CodUsuario = user.CodUsuario
                }));
            }
            try
            {
                if (user.IdEstado == (int)EnumEstadoUsuario.Registrado)
                {
                    return(RedirectToAction("Index", "Registro"));
                }
                //El usuario es valido y puede ingresar
                user.Ticket = SeguridadDelegate.IniciarSesion(user.CodUsuario, user.Ticket);
                var cookie = FormsAuthentication.GetAuthCookie(user.Ticket, false);
                //Decrypt the cookie
                var ticket = FormsAuthentication.Decrypt(cookie.Value);
                //Create a new ticket using the details from
                //the generated cookie, but store the username &
                //token passed in from the authentication method
                var newticket = new FormsAuthenticationTicket(ticket.Version,
                                                              ticket.Name, ticket.IssueDate, ticket.Expiration,
                                                              ticket.IsPersistent, user.CodUsuario);
                //Encrypt the ticket & store in the cookie
                cookie.Value = FormsAuthentication.Encrypt(newticket);
                //Update the outgoing cookies collection.
                Response.Cookies.Set(cookie);
                Session.RemoveAll();
                var url = string.Format(AppProperties.TRANSACURL, user.Locale, user.Ticket);

                string lang    = string.Empty;
                var    idiomas = GeneralesDelegate.ConsultarIdiomas();
                foreach (var i in idiomas)
                {
                    if (i.IdIdioma == user.IdIdioma)
                    {
                        Response.Cookies.Remove(Config.LANG_COOKIE_NAME);

                        lang = i.Abreviatura;
                        var langCookie = new HttpCookie(Config.LANG_COOKIE_NAME, lang)
                        {
                            HttpOnly = true
                        };
                        Response.AppendCookie(langCookie);
                    }
                }

                if (isEmbedded == true)
                {
                    return(Redirect(url));
                }

                return(Json(new
                {
                    redireccionar = url
                }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                Session.RemoveAll();
                throw new ControllerException(RecErrores.Err_LogFallido);
            }
        }