public eeResultLogin Login(string NameUser, string Pass, string CorreoUser, string UserIP, string UserIP2, ref bool IsMismIP) { bool UsuarioFinalizoSesionAnterior = false; int IdSesionPorFinalizarFechaUsuario = -1; eeResultLogin Res = eeResultLogin.UserNoExiste; string SQL = "READ_USER_LOGIN"; //"SELECT * FROM TBL_BUS_Usuario WHERE UserNameLogin = '******' AND Password = '" + Pass +¿ DALCSQLServer DALC = this.GetCommonDalc(); ArrayList parametros = new ArrayList(); SqlParameter param = new SqlParameter("@NameUser", NameUser); parametros.Add(param); string PassEncripted = Security.Seguridad.EncriptarPass(Pass); param = new SqlParameter("@Password", PassEncripted); parametros.Add(param); this.Datos = DALC.ExecuteStoredProcedure("USER_READ_LOGIN", parametros); if (this.Datos.Rows.Count == 0) { return(Res); } this.Id = this.Datos.Rows[0]["Id"].ToString(); this.NombreLargo = this.Datos.Rows[0]["NombreLargo"].ToString(); this.H2QAccess = bool.Parse(this.Datos.Rows[0]["H2QAccess"].ToString()); this.MunicipioAccess = bool.Parse(this.Datos.Rows[0]["MunicipioAccess"].ToString()); this.UCivilAccess = bool.Parse(this.Datos.Rows[0]["UCivilAccess"].ToString()); this.ReadById(); Res = eeResultLogin.LoginExitoMismaIP; DALC = null; return(Res); }
protected void btnLogin_Click(object sender, EventArgs e) { if (this.txtName.Text.Trim().Length == 0 || this.txtPass.Text.Trim().Length == 0) { return; } Usuario usuario = new Usuario(); string userHostAddress = this.Request.UserHostAddress; string userIp = this.GetUserIP(); bool IsMismIP = false; eeResultLogin eeResultLogin = usuario.Login(this.txtName.Text, this.txtPass.Text, "", userHostAddress, userIp, ref IsMismIP); switch (eeResultLogin) { case eeResultLogin.UserNoExiste: this.Response.Redirect("UserNoAuthorized.aspx", true); break; case eeResultLogin.LoginExitoMismaIP: case eeResultLogin.LoginExitoDistintaIP: if (eeResultLogin == eeResultLogin.LoginExitoDistintaIP) { this.Response.Redirect("UserNoAuthorized.aspx", true); break; } string Token = ""; string StringOfControl = ""; string Serial = ""; string stringSecure = UtilWeb.GenerateStringSecure(usuario.Id, ref StringOfControl, ref Serial, ref Token); usuario.CreateSesionHistory(Token, DateTime.Now, userHostAddress, userIp, stringSecure, StringOfControl); this.Response.Cookies.Add(new HttpCookie("QS", "s=" + Token) { Expires = DateTime.Now.AddMinutes(double.Parse(ConfigurationManager.AppSettings["MinutesSession"].ToString())) }); //Procesa tareas batch if (ConfigurationManager.AppSettings["Ejecutar_Carga_Fleetup"].ToString().ToUpper() == "TRUE") { FleetUpRecordVehPasoGeoCerca batch = new FleetUpRecordVehPasoGeoCerca(usuario); batch.ProcesarTareasBatchWialon(usuario); } if (usuario.H2QAccess) { this.Response.Redirect("registro_municipio.html", false); //this.Response.Redirect("RegistroClientes.html", false); } if (usuario.MunicipioAccess) { this.Response.Redirect("municipio_menu.html", false); // this.Response.Redirect("registro_ot_copia.html", false); } break; } }
public eeResultLogin LoginUserCliente(string NameUser, string Pass, string CorreoUser, string UserIP, string UserIP2, ref bool IsMismIP) { bool UsuarioFinalizoSesionAnterior = false; int IdSesionPorFinalizarFechaUsuario = -1; eeResultLogin Res = eeResultLogin.UserNoExiste; string SQL = "READ_USER_LOGIN"; DALCSQLServer DALC = this.GetCommonDalc(); ArrayList parametros = new ArrayList(); SqlParameter param = new SqlParameter("@NameUser", NameUser); parametros.Add(param); string PassEncripted = Security.Seguridad.EncriptarPass(Pass); param = new SqlParameter("@Password", PassEncripted); parametros.Add(param); this.Datos = DALC.ExecuteStoredProcedure("USER_READ_LOGIN", parametros); if (this.Datos.Rows.Count == 0) { return(Res); } this.Id = this.Datos.Rows[0]["Id"].ToString(); this.NombreLargo = this.Datos.Rows[0]["NombreLargo"].ToString(); //Se lee la entidad completa this.ReadById(); if (this.Persona.DREntity["IdCliente"] == DBNull.Value) { return(Res); } if (!bool.Parse(this.Persona.DREntity["CuentaExterna"].ToString())) { return(Res); } ////Se verifica si tiene Rol de Cliente y a tarea específica //Seguridad seg = new Seguridad(); //if (! seg.UserHaveAccess(this, "ACCESS_MODULO_CLIENTES")) //{ // return Res; //} Res = eeResultLogin.LoginExitoMismaIP; DALC = null; return(Res); }