public bool Edit()
        {
            try
            {
                string    sql = "SELECT TOP 1 * FROM USUARIOS WHERE PK1=" + Id;
                ResultSet res = db.getTable(sql);

                if (res != null && res.Next())
                {
                    Usuario  = res.Get("USUARIO");
                    Nombre   = res.Get("NOMBRE");
                    APaterno = res.Get("APATERNO");
                    AMaterno = res.Get("AMATERNO");
                    RFC      = res.Get("RFC");
                    Edad     = res.Get("EDAD");
                    try
                    {
                        Password = EncryptX.Decode(res.Get("PASSWORD"));
                    }
                    catch { Password = ""; }

                    Activo         = res.Get("ACTIVO") == "True" ? "1" : "0";
                    SedePrincipal  = res.Get("CVE_SEDE");
                    SedePrincipal  = SedePrincipal == "" ? "0" : SedePrincipal;
                    IdsSedesAcceso = EditSedes(res.Get("PK1"));

                    Roles = EditRoles(res.Get("PK1"));

                    return(true);
                }
            }
            catch (Exception) { }
            return(false);
        }
        public bool Validate_Usuario_Admin(string client_user, string client_password, LoginModel model)
        {
            bool _valido = false;

            if (client_password != "")
            {
                string server_password = model.consultaPassword(client_user);
                string password        = EncryptX.Decode(server_password);

                if (EncryptX.check(server_password, client_password))
                {
                    database db = new database();
                    SessionDB.afterLogIn(client_user, db, Request, Response);
                    SessionDB sesion = SessionDB.start(Request, Response, false, db);

                    //Log.write(this, "Validate", LOG.CONSULTA, "Detalle x", sesion);

                    _valido = true;
                }
                else
                {
                    ViewBag.Mensaje = "Su password es incorrecto";
                }
            }
            else
            {
                ViewBag.Mensaje = "Ups, falta escribir su password";
            }

            return(_valido);
        }
 public ActionResult KeepSession()
 {
     try
     {
         string session_val = EncryptX.Decode(Request.Params["session_val"]);
         if (SessionDB.KeepSession(session_val, new database(), Request, Response))
         {
             return(Content("ok"));
         }
     }
     catch { }
     return(Content("-1"));
 }
        private string CreateMenuInfoUser(SessionDB sesion)
        {
            string menu = new StringBuilder()
                          .Append("<li class=\"dropdown navbar-ser\"><a href=\"javascript:; \" class=\"dropdown-toggle\" data-toggle=\"dropdown\"> ")
                          .Append("<img src=\"/Content/images/user.png\" width=\"\" height=\"30px\"  /> <span class=\"hidden-xs\">")
                          .Append("" + sesion.completeName)
                          .Append("</span> <b class=\"caret\"></b></a>")
                          .Append(" <ul class=\"dropdown-menu animated fadeInLeft\"> ")

                          .Append("<li><a href=\"/Login/Close \">Cerrar Sesión</a></li> ")
                          .Append("</ul></li> ")
                          .Append("<input type=\"hidden\" id=\"session_val\" value=\"")
                          .Append(EncryptX.Encode("" + sesion.pkUser + "," + sesion.idSesion)).Append("\"> ")
                          .ToString();

            return(menu);
        }
示例#5
0
        public ActionResult EditaPassword(Models.PasswordModel model)
        {
            try
            {
                Debug.WriteLine("enrto class edit: ");

                if (model.ActualizaPassword(EncryptX.Encode(model.password), EncryptX.Encode(model.passwordActual)))
                {
                    return(Json(new { msg = Notification.Succes("Se ha editado con exito el Password") }));
                }
                else
                {
                    return(Json(new { msg = Notification.Succes("Error al Editar Password") }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { msg = Notification.Error(e.Message) }));
            }
        }
示例#6
0
        public ActionResult ValidaPassword(Models.PasswordModel model)
        {
            try
            {
                Debug.WriteLine("enrto class: ");

                if (model.ValidaPassword(EncryptX.Encode(model.passwordActual)))
                {
                    return(Json(new { msg = "Existe" }));
                }
                else
                {
                    return(Json(new { msg = "No Existe" }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { msg = Notification.Error(e.Message) }));
            }
        }
        private Dictionary <string, string> prepareData(bool add)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("USUARIO", Usuario);
            dic.Add("PASSWORD", EncryptX.Encode(Password));
            dic.Add("NOMBRE", Nombre);
            dic.Add("APATERNO", APaterno);
            dic.Add("AMATERNO", AMaterno);
            dic.Add("RFC", RFC);
            dic.Add("EDAD", Edad);
            dic.Add("ACTIVO", Activo);
            dic.Add("CVE_SEDE", SedePrincipal);
            if (add)
            {
                dic.Add("FECHA_R", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
            }
            else
            {
                dic.Add("FECHA_M", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
            }
            dic.Add("PK_USUARIO", sesion.pkUser.ToString());
            return(dic);
        }