Exemple #1
0
        public ActionResult UsersEdit(Users user)
        {
            string userIpAddress = this.Request.UserHostAddress;

            try
            {
                String Action = "";
                if (validateUser(user))
                {
                    //Password validation
                    if ((user.PasswordHash.Length >= 8) && (user.ConfirmPassword.Length >= 8) && (user.ConfirmPassword.Length >= 8) && user.ConfirmPassword == user.ConfirmPassword2)
                    {
                        user.email = Session["email"].ToString();
                        int perfil = DBcontext.LoginUser(new Models.Login(user.email, user.PasswordHash));
                        if (perfil == 1 || perfil == 2)
                        {
                            user.PasswordHash = user.ConfirmPassword;
                            if (DBcontext.ActualizarUsuario(user) == true)
                            {
                                clearPassword(user);
                                Session["mensaje"] = "correcto";
                                //Traking
                                Action = "Editar datos de usuario correcto";
                                String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
                                location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name;
                                TrackLog(location, Action);

                                return(View());
                            }
                            else
                            {
                                clearPassword(user);
                                Session["mensaje"] = "incorrecto";
                                //Traking
                                Action = "Editar datos de usuario incorrecto";
                                String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
                                location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name;
                                TrackLog(location, Action);

                                return(View());
                            }
                        }
                        else
                        {
                            clearPassword(user);
                            Session["mensaje"] = "incorrecto";
                            //Traking
                            Action = "Editar datos de usuario incorrecto";
                            String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
                            location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name;
                            TrackLog(location, Action);

                            return(View());
                        }
                    }
                    else
                    {
                        clearPassword(user);
                        Session["mensaje"] = "incorrecto";
                        //Traking
                        Action = "Editar datos de usuario incorrecto";
                        String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
                        location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name;
                        TrackLog(location, Action);
                    }


                    return(View());
                }
                return(View());
            }
            catch (Exception ex)
            {
                clearPassword(user);
                Session["mensaje"] = "incorrecto";
                //Log error
                DBcontext.setPiactProblem(ex.Message, ex.StackTrace, Session["email"].ToString(), userIpAddress, "BETA");

                return(View());
                //saveLog;
            }
        }
Exemple #2
0
        public ActionResult Index(Login user)
        {
            try
            {
                /*var response = Request["g-recaptcha-response"];
                 * string secretKey = "6Ldd7BsUAAAAAPV5qQigjCeqN53JJVn0vpsu1Sc1";
                 * var client = new WebClient();
                 * var result = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response));
                 * var obj = JObject.Parse(result);
                 * var status = (bool)obj.SelectToken("success");
                 * if (status == false)
                 * {
                 *  ViewBag.Message = "Por favor, verifica que no eres un robot.";
                 * }
                 * else
                 * {*/
                String Action = "";
                if (ModelState.IsValid || user.email != null)
                {
                    int perfil = DBcontext.LoginUser(user);

                    ModelState.Clear();

                    if (perfil == 1 || perfil == 2)
                    {
                        Session["email"]  = user.email.ToString();
                        Session["perfil"] = perfil;
                        //Session["email"] = form["usuarioAP"].ToString();
                        if (perfil == 1 || perfil == 2)
                        {
                            //Traking log
                            Session["mensaje"] = "Login";
                            Action             = "Login";

                            String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
                            location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name;
                            TrackLog(location, Action);
                            return(RedirectToAction("Index", "Publisher"));
                        }
                        // return RedirectToAction("LoggedIn");
                    }
                    else if (perfil == 0)
                    {
                        Action = "Lo sentimos, el email de usuario es incorrecto";
                        String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
                        location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name;
                        TrackLog(location, Action);
                        ViewBag.Message = "Lo sentimos, el email de usuario es incorrecto";
                    }
                    else if (perfil == -1)
                    {
                        Action = "Lo sentimos, su contraseña es incorrecto";
                        String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
                        location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name;
                        TrackLog(location, Action);
                        ViewBag.Message = "Lo sentimos, su contraseña es incorrecto";
                    }
                }
                /*}*/

                return(View());
            }


            catch (Exception ex)
            {
                string userIpAddress = this.Request.UserHostAddress;

                ViewBag.Message = "Error en el proceso de autenticación, por favor contactar al equipo de desarrollo PIACT";
                DBcontext.setPiactProblem(ex.Message, ex.StackTrace, userIpAddress, "IP", "BETA");
                return(View());
            }
        }