Exemple #1
0
        // GET: tbl_usuario
        public ActionResult Index()
        {
            cerinfoEntities    DB   = new cerinfoEntities();
            List <tbl_usuario> user = DB.tbl_usuario.ToList();

            return(View(user));
        }
Exemple #2
0
        public ActionResult Auth(Contrasena C)
        {
            con.Open();
            com.Connection = con;


            string          usuario           = C.username;
            string          contrasena        = C.antiguaContrasena;
            string          newContrasena     = C.nuevaContrasena;
            string          confirmContrasena = C.confirmarContrasena;
            cerinfoEntities DB = new cerinfoEntities();

            if (newContrasena.Equals(confirmContrasena) && newContrasena.Length > 6)
            {
                ViewBag.showSuccessAlert = true;
                string pcontrasena    = GetSHA1(newContrasena);
                string pcontrasenaOld = GetSHA1(contrasena);
                try
                {
                    com.CommandText = "UPDATE tbl_usuario SET contrasena='" + pcontrasena + "' WHERE nombre_usuario='" + usuario + "' AND contrasena = '" + pcontrasenaOld + "'";

                    com.ExecuteReader();
                    con.Close();
                    return(View("~/Views/Home/Index.cshtml"));
                }
                catch (Exception)
                {
                    return(View("Error"));

                    throw;
                }
            }
            else
            {
                return(View("Error"));
            }
        }
Exemple #3
0
        public ActionResult Auth(Login L)
        {
            con.Open();
            com.Connection = con;


            string          usuario    = L.username;
            string          contrasena = L.password;
            cerinfoEntities DB         = new cerinfoEntities();

            // var persona = DB.tbl_usuario.Where(x => x.nombre_usuario == usuario).FirstOrDefault();
            //Generar algoritmo de encryptacion
            // String salt = cryptoService.GenerateSalt();
            //String contrasenaencryptada = cryptoService.Compute(L.password);
            //com.CommandText = "SELECT * FROM tbl_usuario WHERE nombre_usuario='"+L.username+"' AND contrasena='"+L.password+"'";
            // Con password encryptado
            //com.CommandText = "SELECT * FROM tbl_usuario WHERE nombre_usuario='" + L.username + "' AND contrasena='" + contrasenaencryptada + "'";
            //ICryptoService cryptoService = new PBKDF2();
            //string contrasenaEncryptada = cryptoService.Compute(contrasena,persona.salt);
            string pcontrasena = GetSHA1(contrasena);

            com.CommandText = "SELECT * FROM tbl_usuario WHERE nombre_usuario='" + usuario + "' AND contrasena='" + pcontrasena + "'";


            dr = com.ExecuteReader();
            if (dr.Read())
            {
                con.Close();
                return(View("~/Views/Home/Index.cshtml"));
            }
            else
            {
                con.Close();
                return(View("Error"));
            }
        }