protected void btnForgotUsername_Click(object sender, EventArgs e) { //TODO-Rick-1 Use the email address to go get the username and email it to them. If that email address has multiple usernames, send them all of them. if (txtEmailAddress.Text == "") { lblUsernameISEmail.Text = "Fill in the email address and click the 'Forgot Username' button again."; } else { Classes.cLogin ValidUser = new Classes.cLogin(); ValidUser.GetUsernameByEmail(txtEmailAddress.Text); if (ValidUser.Email == "") { lblUsernameISEmail.Text = "This email address is not associated with a LARP Portal account. Please click 'Sign Up' to create an account."; } else { if (ValidUser.Email == ValidUser.Username) { lblUsernameISEmail.Text = "Your email address is your username. We recommend you change your username after logging in."; txtUsername.Text = ValidUser.Username; } else { //TODO-Rick-1 Send an email to the user with just their username. ForgotUsername(txtEmailAddress.Text); lblUsernameISEmail.Text = "An email has been sent to this email address with your username. Use that username to fill out this form and complete the process."; } } } lblUsernameISEmail.Visible = true; }
protected void ForgotUsername(string EmailAddress) { string strBody; string FirstName = ""; string LastName = ""; string LoginUsername = ""; Classes.cLogin Username = new Classes.cLogin(); Username.GetUsernameByEmail(EmailAddress); FirstName = Username.FirstName; LastName = Username.LastName; LoginUsername = Username.Username; string strSubject = "Your LARP Portal Username"; strBody = "Hi " + FirstName + ",<p></p><p></p>Your LARP Portal username is <b>" + LoginUsername + "</b>. If you need further assistance please contact us "; strBody = strBody + "via email at [email protected].<br><br>"; strBody = strBody + @"Click <u><a href=""https://www.larportal.com"">here</a></u> to log in."; Classes.cEmailMessageService MailServer = new Classes.cEmailMessageService(); try { MailServer.SendMail(strSubject, strBody, EmailAddress, "", "", "ForgotUsername", "System"); mvInfoRequest.SetActiveView(vwSentEmail); } catch (Exception) { mvInfoRequest.SetActiveView(vwIssue); } }
protected void ForgotUsername(string EmailAddress) { string strBody; string FirstName = ""; string LastName = ""; string LoginUsername = ""; Classes.cLogin Username = new Classes.cLogin(); Username.GetUsernameByEmail(EmailAddress); FirstName = Username.FirstName; LastName = Username.LastName; LoginUsername = Username.Username; string strFromUser = "******"; string strFromDomain = "larportal.com"; string strFrom = strFromUser + "@" + strFromDomain; string strSMTPPassword = "******"; string strSubject = "Your LARP Portal Username"; strBody = "Hi " + FirstName + ",<p></p>Your LARP Portal username is " + LoginUsername + ". If you need further assistance please contact us "; strBody = strBody + "contact us via email at [email protected]."; MailMessage mail = new MailMessage(strFrom, EmailAddress); SmtpClient client = new SmtpClient("smtpout.secureserver.net", 80); client.EnableSsl = false; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential(strFrom, strSMTPPassword); client.Timeout = 10000; mail.Subject = strSubject; mail.Body = strBody; mail.IsBodyHtml = true; try { client.Send(mail); } catch (Exception) { lblUsernameISEmail.Text = "There was an issue. Please contact us at [email protected] for assistance."; lblUsernameISEmail.Visible = true; } }
protected void btnGetUsername_Click(object sender, EventArgs e) { Classes.cLogin ValidUser = new Classes.cLogin(); ValidUser.GetUsernameByEmail(txtEmailAddress.Text); if (ValidUser.Email == "") { divInvalid.Visible = true; } else { if (ValidUser.Email == ValidUser.Username) { lblMessage.Text = "Your email address is your username. We recommend you change your username after logging in."; mvInfoRequest.SetActiveView(vwSentEmail); } else { lblMessage.Text = "An email has been sent to this email address with your username. Use that username to fill out this form and complete the process."; ForgotUsername(txtEmailAddress.Text); } } }
protected void btnSignUp_Click(object sender, EventArgs e) { if (Session["AttemptedPassword"] == null) { txtPasswordNew.Text = ""; } else { txtPasswordNew.Text = Session["AttemptedPassword"].ToString(); txtPasswordNew.Attributes.Add("value", txtPasswordNew.Text); } if (Session["AttemptedPasswordRetype"] == null) { txtPasswordNewRetype.Text = ""; } else { txtPasswordNewRetype.Text = Session["AttemptedPasswordRetype"].ToString(); txtPasswordNewRetype.Attributes.Add("value", txtPasswordNewRetype.Text); } if (Page.IsValid) { lblSignUpErrors.Text = ""; // 1 - No duplicate usernames allowed Classes.cLogin Login = new Classes.cLogin(); Login.CheckForExistingUsername(txtNewUsername.Text); if (Login.MemberID != 0) // UserID is taken { lblSignUpErrors.Text = "This username is already in use. Please select a different one."; } // 2 - Password must meet parameter standards int ValidPassword; Classes.cLogin PasswordValidate = new Classes.cLogin(); PasswordValidate.ValidateNewPassword(txtPasswordNew.Text); ValidPassword = PasswordValidate.PasswordValidation; if (ValidPassword == 0) { if (lblSignUpErrors.Text != "") { lblSignUpErrors.Text = lblSignUpErrors.Text + "<p></p>" + PasswordValidate.PasswordFailMessage + "."; } else { lblSignUpErrors.Text = PasswordValidate.PasswordFailMessage + "."; } } // 3 - Both passwords must be the same if (txtPasswordNew.Text != txtPasswordNewRetype.Text) //set an error message { if (lblSignUpErrors.Text != "") { lblSignUpErrors.Text = lblSignUpErrors.Text + "<p></p>Passwords don't match. Please re-enter."; } else { lblSignUpErrors.Text = "Passwords don't match. Please re-enter."; } txtPasswordNew.Text = ""; txtPasswordNewRetype.Text = ""; } // 4 - New request - If the email address is already on file, warn them and suggest they go to the Forgot Username / Password section Classes.cLogin ExistingEmailAddress = new Classes.cLogin(); ExistingEmailAddress.GetUsernameByEmail(txtEmail.Text); if (ExistingEmailAddress.Username != "") { if (lblSignUpErrors.Text != "") { lblSignUpErrors.Text = lblSignUpErrors.Text + "<p></p>This email address is already associated with an account. If you've forgotten your username or password, please use the link above."; } else { lblSignUpErrors.Text = "This email address is already associated with an account. If you've forgotten your username or password, please use the link above."; } } // If there were errors, display them and return to form if (lblSignUpErrors.Text != "") { lblSignUpErrors.Visible = true; txtNewUsername.Focus(); } else { // Everything is ok. Create the record. If successful, go to the member demographics screen. Classes.cUser NewUser = new Classes.cUser(txtNewUsername.Text, txtPasswordNew.Text); NewUser.FirstName = txtFirstName.Text; NewUser.LastName = txtLastName.Text; NewUser.LoginPassword = txtPasswordNew.Text; NewUser.LoginEmail = txtEmail.Text; NewUser.LoginName = txtNewUsername.Text; NewUser.Save(); Classes.cLogin Activation = new Classes.cLogin(); Activation.Load(txtNewUsername.Text, txtPasswordNew.Text); string ActivationKey = ""; ActivationKey = Activation.SecurityResetCode; GenerateWelcomeEmail(txtFirstName.Text, txtLastName.Text, txtNewUsername.Text, txtEmail.Text, ActivationKey); Response.Write("<script>"); Response.Write("window.open('NewUserLoginDirections.aspx','_blank')"); Response.Write("</script>"); // TODO-Rick-0e Account for versioning of 'terms of use' and keeping track of date/time and which version user agreed to } } else { // TODO-Rick-3 On create user if something totally unexpected is wrong put up a message } }