Esempio n. 1
0
        //
        // GET: /Token/
        public ActionResult Index()
        {
            clsModelLogin model = new clsModelLogin();

            model.Usuario = "";
            model.EncPass = "";
            model.Mensaje = "";

            return(View(model));
        }
Esempio n. 2
0
        public ActionResult Ingreso(clsModelLoginIngreso pDatos)
        {
            string accion      = "";
            string controlador = "";

            //Valida usuario y clave
            clsWebApi            objServicio = new clsWebApi("url_api");
            List <clsModelLogin> lst         = new List <clsModelLogin>();

            //using System.Configuration;
            string EncKeyBase = "";

            EncKeyBase = ConfigurationManager.AppSettings["enc_key_base"].ToString();
            clsEncryption Encryption = new clsEncryption(EncKeyBase);

            clsModelLogin item = new clsModelLogin();

            item.Usuario = pDatos.Usuario;
            item.EncPass = Encryption.fnGetEncrypt(pDatos.Clave);

            lst.Add(item);

            List <clsModelLogin> lsusuario = new List <clsModelLogin>();
            IRestResponse        task      = Task.Run(() => objServicio.fnEjecutarPostObject("Login/Ingreso", lst)).Result;

            if (task.StatusCode == System.Net.HttpStatusCode.OK)
            {
                lsusuario = JArray.Parse(task.Content).ToObject <List <clsModelLogin> >();

                Session["Usr"]       = lsusuario[0].Usuario;
                Session["UsrNombre"] = lsusuario[0].Nombre;
                Session["UsrToken"]  = lsusuario[0].Token;

                Session["UsrUltMensaje"] = "Acceso otorgado";

                accion      = "Index";
                controlador = "Home";
            }
            else if (task.StatusCode == System.Net.HttpStatusCode.NotFound)
            {
                Session["UsrUltMensaje"] = "No existe API de respuesta";

                accion      = "Failed";
                controlador = "Login";
            }
            else if (task.StatusCode == System.Net.HttpStatusCode.Unauthorized)
            {
                Session["UsrUltMensaje"] = task.Content.ToString();

                accion      = "Failed";
                controlador = "Login";
            }
            else
            {
                Session["UsrUltMensaje"] = "Error al consultar el API " + task.StatusDescription.ToString() + " " + task.StatusCode.ToString();
                accion      = "Failed";
                controlador = "Login";
            }

            //return RedirectToAction("Index", "Home");
            return(RedirectToAction(accion, controlador));
        }
Esempio n. 3
0
        public ActionResult fnGetTokenByUser(clsModelLogin model)
        {
            model.Mensaje = "Token :";

            return(View("Index", model));
        }