//reset the password protected void btnSubmit_Click(object sender, EventArgs e) { CustomerLogin reset = new CustomerLogin(); string oldPwd = txtOldPassword.Text; string newPwd = txtNewPassword.Text; string confirmPwd = txtConfirmPwd.Text; if (!CustomerDB.CheckPassword((int)Session["CustomerId"], oldPwd)) { lblResetError.Text = "Current password incorrect. Please try again."; } else // do reset { reset.CustomerId = (int)Session["CustomerId"]; reset.Password = newPwd; try { if (CustomerDB.ResetCustomerPassword(reset)) { lblResetError.Text = "Reset successfully."; } } catch (Exception ex) { lblResetError.Text = ex.Message; } } }
/// <summary> /// Handles the Click event of the btnLogin control. /// Tries to log the user in if the password is correct /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void btnLogin_Click(object sender, EventArgs e) { int?customerID = GetLoginID(); if (customerID == null || !CustomerDB.CheckPassword(customerID.Value, txtLoginPassword.Text)) { return; } Login(customerID.Value); }
/// <summary> /// Handles the ServerValidate event of the loginPasswordValidator control. /// Checks that the given login password is a match for the username /// </summary> /// <param name="source">The source of the event.</param> /// <param name="args">The <see cref="ServerValidateEventArgs"/> instance containing the event data.</param> protected void loginPasswordValidator_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = false; string pwInput; if (txtLoginPassword.Text == String.Empty) { return; } else { pwInput = txtLoginPassword.Text; } int?customerID = GetLoginID(); if (customerID != null && CustomerDB.CheckPassword(customerID.Value, pwInput)) { args.IsValid = true; } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { bool customerExists = false; string custEmail = Login1.UserName; string custPassword = Login1.Password; //get user's password and email to check with database customerExists = CustomerDB.CheckPassword(custEmail, custPassword); if (customerExists) { Session["user"] = CustomerDB.GetCustomerByEmail(custEmail); Session["userID"] = CustomerDB.GetCustomerByEmail(custEmail).CustomerID; Session["userName"] = CustomerDB.GetCustomerByEmail(custEmail).CustFirstName; Response.Redirect("Customer.aspx");//Redirecting user to main page after loggin } else { Login1.FailureText = "Invalid username or password."; } }