protected void Unnamed_Click(object sender, EventArgs e) { HttpPostedFile file = pictureUpload.PostedFile; HttpCookie cookie = Request.Cookies["damncookie"]; if (cookie != null) { if (file != null && file.ContentLength > 0) { string fname = Path.GetFileName(file.FileName); url = Path.Combine("~/Imagenes/Users/", fname); file.SaveAs(Server.MapPath(url)); } ENUser user = new ENUser(); if (name.Text == "") { user.name = nameText; } else { user.name = name.Text; } if (pass.Text == "") { user.pass = passw; } else { user.pass = pass.Text; } user.url = url; if (address.Text == "") { user.address = addressText; } else { user.address = address.Text; } user.email = cookie["username"]; if (user.UpdateUser()) { Response.Redirect("Perfil.aspx?ok=" + name.Text); } } }
protected void Send_email_Click(object sender, EventArgs e) { ClearBoxes(); // If email exists in DB, change password for that email and send it back to that email address. ENUser user = new ENUser(); user.email = recover_email.Text.ToString(); user.ReadUserPerfil(); if (user.email != "") { //Changes DB password for this user byte[] salt; new RNGCryptoServiceProvider().GetBytes(salt = new byte[16]); var pb = new Rfc2898DeriveBytes(user.pass, salt, 1000); byte[] random = pb.GetBytes(20); string newpass = Convert.ToBase64String(random); newpass = newpass.Substring(0, 10); user.pass = newpass; if (user.UpdateUser()) { //If info can be sent, then show success message if (SendMail(user.name, user.email, newpass)) { Label_Sending_Success.Visible = true; } else { Label_Main.Text = "Ocurrió un error inesperado al enviar su email, contacte con un administrador."; Label_Main.Visible = true; } } else { Label_Update_Error.Visible = true; } } else { Label_Finding_Error.Visible = true; } }