/// <summary> /// Validar credenciales de un cliente /// </summary> /// <param name="_datos">Objeto con datos de conexión y parámetros (Usuario y contraseña)</param> /// <returns></returns> public CH_Cliente Login(CH_Cliente _datos) { try { CH_ClienteDatos clienteDatos = new CH_ClienteDatos(); return(clienteDatos.Login(_datos)); } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.IsAuthenticated) { FormsAuthentication.SignOut(); } } if (Request.Form.Count > 0) { string usuario = Request.Form["email"]; string password = Request.Form["password"]; bool rememberMe = true; CH_Cliente dataCustomer = new CH_Cliente { Conexion = Comun.Conexion, Correo = usuario, Password = password }; CH_ClienteNegocio custNeg = new CH_ClienteNegocio(); CH_Cliente dataResult = custNeg.Login(dataCustomer); if (dataResult.Completado && dataResult.Resultado == 1) { //string userDataString = string.Concat(companyName[i], "|", titleAtCompany[i]); // Create the cookie that contains the forms authentication ticket HttpCookie authCookie = FormsAuthentication.GetAuthCookie(dataResult.IdCliente, rememberMe); // Get the FormsAuthenticationTicket out of the encrypted cookie FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); // Create a new FormsAuthenticationTicket that includes our custom User Data CH_ClienteJson data = dataResult.GetClienteJson(); string userDataString = JsonConvert.SerializeObject(data); FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, userDataString); // Update the authCookie's Value to use the encrypted version of newTicket authCookie.Value = FormsAuthentication.Encrypt(newTicket); // Manually add the authCookie to the Cookies collection Response.Cookies.Add(authCookie); // Determine redirect URL and send user there //string redirUrl = FormsAuthentication.GetRedirectUrl(idUsuario, rememberMe); string redirUrl = Page.RouteData.Values["ReturnUrl"] != null ? Page.RouteData.Values["ReturnUrl"].ToString() : string.Empty; if (string.IsNullOrEmpty(redirUrl)) { redirUrl = FormsAuthentication.GetRedirectUrl(dataResult.IdCliente, rememberMe); if (redirUrl == null) { redirUrl = "/Home"; } } else { redirUrl = "/" + redirUrl; } Response.Redirect(redirUrl, true); } } }
public RR_MiCuenta ObtenerDatosCuenta(RR_MiCuenta Datos) { try { object[] Parametros = { Datos.Cliente.IdCliente }; RR_MiCuenta DatosCuenta = new RR_MiCuenta(); DataSet ds = SqlHelper.ExecuteDataset(Datos.Conexion, "RR_spCSLDB_getDatosCliente", Parametros); if (ds != null) { if (ds.Tables.Count == 1) { DataTableReader dr = ds.Tables[0].CreateDataReader(); List <CH_Cliente> listaCuenta = new List <CH_Cliente>(); CH_Cliente itemCuenta; while (dr.Read()) { itemCuenta = new CH_Cliente(); itemCuenta.IdCliente = dr.GetString(dr.GetOrdinal("id_cliente")); itemCuenta.Nombre = dr.GetString(dr.GetOrdinal("nombre")); itemCuenta.ApPat = dr.GetString(dr.GetOrdinal("apePat")); itemCuenta.ApMat = dr.GetString(dr.GetOrdinal("apeMat")); itemCuenta.Correo = dr.GetString(dr.GetOrdinal("correoElectronico")); itemCuenta.IdPais = dr.GetInt32(dr.GetOrdinal("id_pais")); itemCuenta.IdEstado = dr.GetInt32(dr.GetOrdinal("id_estado")); itemCuenta.IdMunicipio = dr.GetInt32(dr.GetOrdinal("id_municipio")); itemCuenta.Colonia = dr.GetString(dr.GetOrdinal("colonia")); itemCuenta.Telefono = dr.GetString(dr.GetOrdinal("telefono")); itemCuenta.Password = dr.GetString(dr.GetOrdinal("password")); itemCuenta.Direccion = dr.GetString(dr.GetOrdinal("direccion")); listaCuenta.Add(itemCuenta); } DatosCuenta.ListaCliente = listaCuenta; } } return(DatosCuenta); } catch (Exception ex) { throw ex; } }