protected void SubmitClicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(email.Text)) { SetError(new Exception("Email address is required.")); pnlForm.Visible = true; } else { try { HarperSecureService.UpdatePasswordResponse updateResponse = new HarperSecureService.UpdatePasswordResponse(); HarperLINQ.tbl_Customer user = new HarperLINQ.tbl_Customer(email.Text, false); if (user == null) { SetError(new Exception("Unable to find a member with this address.")); lblMessage.Text = "Unable to find a member with this email address."; pnlForm.Visible = true; } else { if (string.IsNullOrEmpty(user.cusPassword)) { SetError(new Exception("Error retrieving password - no password or blank password on file.")); lblMessage.Text = string.Format("{0}</br>{1}</br>", new object[] { Resources.GlobalStrings.Apology, Resources.GlobalStrings.ContactUs }); pnlForm.Visible = true; } else { string pwd = Cryptography.Decrypt256FromHEX(user.cusPassword); if (!string.IsNullOrEmpty(user.cusUserName) && !string.IsNullOrEmpty(pwd) && !string.IsNullOrEmpty(email.Text)) { SupportClasses.Mailer Emailer = new SupportClasses.Mailer(); Emailer.SendEmail(ConfigurationManager.AppSettings["mailserviceuser"], ConfigurationManager.AppSettings["mailservicepwd"], "Andrew Harper Password Reminder", ConfigurationManager.AppSettings["MembershipEmailFrom"].ToString(), user.cusEmail, string.Empty, string.Empty, getEmailBody(user.cusUserName, pwd), true, ConfigurationManager.AppSettings["EmailServer"]); lblConfirmation.Visible = true; pnlForm.Visible = false; lblMessage.Visible = false; string s = "<p>As requested, a reminder of your username and password has been sent to " + user.cusEmail + ". Please retrieve your credentials, and use them to log in to our website <a href=\"http://www.andrewharper.com/login\" target=\"_top\">here</a>.</p><p>As a reminder, all username and passwords are case-sensitive.</p><p>If you do not receive the email shortly, please check your spam or junk email folder. If you continue to experience difficulties, please contact Membership at [email protected] or call (866) 831-4314 from the U.S or +1 (512) 904-7342 internationally.</p>"; lblConfirmation.Text = s;// string.Format("A reminder has been sent to {0}. If you do not receive the email within thirty minutes please check your spam or junk email folder.", email.Text); lblConfirmation.Visible = true; WriteLog(string.Format("Password for {0} was sent to {1}", new object[] { user.cusUserName, user.cusEmail })); } else { SetError(new Exception("Unable to send password reminder email.")); lblMessage.Text = "Unable to send password reminder email."; pnlForm.Visible = true; } } } } catch (Exception ex) { SetError(new Exception("Unable to send password reminder email, email address may be duplicate.")); lblMessage.Text = "Unable to send password reminder email, email address may be duplicate."; pnlForm.Visible = true; WriteLog(ex); } } }
protected void SubmitClicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(email.Text)) { SetError(new Exception("Email address is required.")); pnlForm.Visible = true; } else { try { HarperSecureService.UpdatePasswordResponse updateResponse = new HarperSecureService.UpdatePasswordResponse(); HarperLINQ.tbl_Customer user = new HarperLINQ.tbl_Customer(email.Text, false); if (user == null) { SetError(new Exception("Unable to find a member with this address.")); lblMessage.Text = "Unable to find a member with this email address."; pnlForm.Visible = true; } else { if (string.IsNullOrEmpty(user.cusPassword)) { SetError(new Exception("Error retrieving password - no password or blank password on file.")); lblMessage.Text = string.Format("{0}</br>{1}</br>", new object[] { Resources.GlobalStrings.Apology, Resources.GlobalStrings.ContactUs }); pnlForm.Visible = true; } else { string pwd = Cryptography.Decrypt256FromHEX(user.cusPassword); if (!string.IsNullOrEmpty(user.cusUserName) && !string.IsNullOrEmpty(pwd) && !string.IsNullOrEmpty(email.Text)) { SupportClasses.Mailer Emailer = new SupportClasses.Mailer(); Emailer.SendEmail(ConfigurationManager.AppSettings["mailserviceuser"], ConfigurationManager.AppSettings["mailservicepwd"], "Andrew Harper Password Reminder", ConfigurationManager.AppSettings["MembershipEmailFrom"].ToString(), user.cusEmail, string.Empty, string.Empty, getEmailBody(user.cusUserName, pwd), true, ConfigurationManager.AppSettings["EmailServer"]); lblConfirmation.Visible = true; pnlForm.Visible = false; lblMessage.Visible = false; string s = "<p>As requested, a reminder of your username and password has been sent to " + user.cusEmail + ". Please retrieve your credentials, and use them to log in to our website <a href=\"http://www.andrewharper.com/login\" target=\"_top\">here</a>.</p><p>As a reminder, all username and passwords are case-sensitive.</p><p>If you do not receive the email shortly, please check your spam or junk email folder. If you continue to experience difficulties, please contact Membership at [email protected] or call (866) 831-4314 from the U.S or +1 (512) 904-7342 internationally.</p>"; lblConfirmation.Text = s;// string.Format("A reminder has been sent to {0}. If you do not receive the email within thirty minutes please check your spam or junk email folder.", email.Text); lblConfirmation.Visible = true; WriteLog(string.Format("Password for {0} was sent to {1}", new object[] { user.cusUserName, user.cusEmail })); } else { SetError(new Exception("Unable to send password reminder email.")); lblMessage.Text = "Unable to send password reminder email."; pnlForm.Visible = true; } } } } catch (Exception ex) { SetError(new Exception("Unable to send password reminder email, email address may be duplicate.")); lblMessage.Text = "Unable to send password reminder email, email address may be duplicate."; pnlForm.Visible = true; WriteLog(ex); } } }