/// <summary> /// If this is called it means the activation code was entered and is correct. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnValidateAccount_Click(object sender, EventArgs e) { Classes.cLogin Login = new Classes.cLogin(); Login.Load(tbUserName.Text, Session["SavePassword"].ToString()); Login.SecurityResetCode = ""; Login.ClearNewAccount(Login.UserSecurityID, Login.MemberID); MemberLogin(Login); }
protected void btnValidateAccount_Click(object sender, EventArgs e) { Classes.cLogin Login = new Classes.cLogin(); Login.Load(Session["AttemptedUsername"].ToString(), Session["AttemptedPassword"].ToString()); if (txtSecurityResetCode.Text == Login.SecurityResetCode) { Login.SecurityResetCode = ""; Login.ClearNewAccount(Login.UserSecurityID, Login.MemberID); MemberLogin(Session["AttemptedUsername"].ToString(), Session["AttemptedPassword"].ToString()); } else { lblInvalidActivationKey.Visible = true; txtSecurityResetCode.Text = ""; txtSecurityResetCode.Focus(); } }
protected void btnLogin_Click(object sender, EventArgs e) { Session["AttemptedPassword"] = txtPassword.Text; Session["AttemptedUsername"] = txtUserName.Text; if (Page.IsValid) { Classes.cLogin Login = new Classes.cLogin(); Login.Load(txtUserName.Text, txtPassword.Text); if (Login.MemberID == 0) // Invalid user, fall straight to fail logic { Session["SecurityRole"] = 0; lblInvalidLogin.Visible = true; lblInvalidLogin2.Visible = true; Login.LoginFail(txtUserName.Text, txtPassword.Text); } else // Valid member. Is there a lock? { if (Login.SecurityResetCode != "") { if (Login.LoginCount == 0) // New user. First time activation. { lblSecurityResetCode.Text = "Account activation code"; lblSecurityResetCode.ToolTip = "This code can be found in the welcome email that was sent when you registered for a LARP Portal account."; lblSecurityResetCode.Visible = true; Session["SavePassword"] = txtPassword.Text; txtSecurityResetCode.Visible = true; btnValidateAccount.Visible = true; btnLogin.Visible = false; txtSecurityResetCode.Focus(); txtPassword.Text = Session["SavePassword"].ToString(); } else // Existing user with a bigger problem { // TODO-Rick-3 Define how to handle user account locks on attempted login } } else // Valid member. Login. { Login.CheckForEmail(Login.MemberID); MemberLogin(Session["AttemptedUsername"].ToString(), Session["AttemptedPassword"].ToString()); } } } }
protected void btnLogin_Click(object sender, EventArgs e) { Classes.cLogin Login = new Classes.cLogin(); Login.Load(tbUserName.Text, tbPassword.Text); if (Login.MemberID == 0) // Invalid user, fall straight to fail logic { Session["SecurityRole"] = 0; lblInvalidLogin.Visible = true; Login.LoginFail(tbUserName.Text, tbPassword.Text); } else { if (Login.SuperUser) { Session["SuperUser"] = 1; } // Valid member. Is there a lock? if (!String.IsNullOrEmpty(Login.SecurityResetCode)) { if (Login.LoginCount == 0) // New user. First time activation. { mvMainScreen.SetActiveView(vwActivate); hidActivateCode.Value = Login.SecurityResetCode; Session["SavePassword"] = tbPassword.Text; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "MyApplication", "openActivationCode();", true); Session["SavePassword"] = tbPassword.Text; tbActivationCode.Focus(); } else // Existing user with a bigger problem { // TODO-Rick-3 Define how to handle user account locks on attempted login } } else // Valid member. Login. { Login.CheckForEmail(Login.MemberID); MemberLogin(Login); } } }
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 } }
protected void MemberLogin(string AttemptedUsername, string AttemptedPassword) { Classes.cLogin Login = new Classes.cLogin(); string PasswordToUse = txtPassword.Text; if (PasswordToUse == "") { PasswordToUse = AttemptedPassword; } Login.Load(txtUserName.Text, PasswordToUse); int intUserID; int NumberOfCampaigns = 0; string WhereAreYouGoing; Session["MemberEmailAddress"] = Login.Email; Session["SecurityRole"] = Login.SecurityRoleID; txtName.Text = Login.FirstName + " " + Login.LastName; txtLastLocation.Text = Login.LastLoggedInLocation; txtLastCharacter.Text = Login.LastLoggedInCharacter.ToString(); txtLastCampaign.Text = Login.LastLoggedInCampaign.ToString(); txtUserID.Text = Login.MemberID.ToString(); intUserID = Login.MemberID; NumberOfCampaigns = Login.NumberOfCampaigns; Session["LoginName"] = Login.FirstName; Session["UserFullName"] = Login.FirstName + " " + Login.LastName; Session["Username"] = Session["AttemptedUsername"]; Session["LoginPassword"] = Session["AttemptedPassword"]; Session["UserID"] = Login.MemberID; if (txtLastCharacter.Text != "0") { Session["SelectedCharacter"] = txtLastCharacter.Text; } if (txtLastCampaign.Text != "0") { Session["CampaignID"] = txtLastCampaign.Text; } // Write login entry to UserLoginAudit table string txtIPAddress = ""; string txtBrowser = ""; string txtBrowserVersion = ""; string txtPlatform = ""; string txtOSVersion = ""; if (Session["IPAddress"] != null) { txtIPAddress = Session["IPAddress"].ToString(); } if (Session["Browser"] != null) { txtBrowser = Session["Browser"].ToString(); } if (Session["BrowserVersion"] != null) { txtBrowserVersion = Session["BrowserVersion"].ToString(); } if (Session["Platform"] != null) { txtPlatform = Session["Platform"].ToString(); } if (Session["OSVersion"] != null) { txtOSVersion = Session["OSVersion"].ToString(); } Login.LoginAudit(Login.MemberID, txtUserName.Text, txtPassword.Text, txtIPAddress, txtBrowser, txtBrowserVersion, txtPlatform, txtOSVersion); Session["WebPage"] = Login.LastLoggedInLocation; Session["LastLoggedInLocation"] = Login.LastLoggedInLocation; // If no campaigns on My Campaign list (i.e. no CMCampaignPlayers records for UserID) send them to campaign pick page if (NumberOfCampaigns < 1) { Response.Redirect("~/Index1.aspx"); } // Go to the default or last page visited if (Session["WebPage"] == null) { Session["WebPage"] = "~/General/MemberHome.aspx"; } else { if (txtLastLocation.Text == "") { txtLastLocation.Text = "Profile/Demographics.aspx"; } string FirstChar = txtLastLocation.Text.Substring(1, 1); int LocationLength = txtLastLocation.Text.Length; if (FirstChar == "/") { LocationLength = LocationLength - 1; txtLastLocation.Text = txtLastLocation.Text.Substring(2, LocationLength); } Session["WebPage"] = "~/" + txtLastLocation.Text; } WhereAreYouGoing = Session["WebPage"].ToString(); Response.Redirect(Session["WebPage"].ToString()); }