protected void RegisterUser_CreatedUser(object sender, EventArgs e) { FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie: false); string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (!OpenAuth.IsLocalUrl(continueUrl)) { continueUrl = "~/"; } //Added feb 03 2015 Brodie TextBox email = RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Email") as TextBox; string eMail = email.Text; Session["newEmail"] = eMail; Customer newuser = CustomerDB.GetCustomerByEmail(eMail); if (newuser == null) { Session["loggedin"] = true; Session["new"] = true; } else { Response.Write("<script>alert('User Email Already Exists!');</script>"); } //End of Brodie Addition Response.Redirect(continueUrl); }
/// <summary> /// Handles the ServerValidate event of the emailExistsValidator control. /// Checks whether an email already exists in the Customer database /// </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 emailExistsValidator_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = false; string emailInput = txtEmail.Text; Customer existingCust = CustomerDB.GetCustomerByEmail(emailInput); if (existingCust == null) //Email does not exist in database { args.IsValid = true; } }
protected void Login_Click(object sender, EventArgs e) { //Brodie Added Feb 03 2015 string user = ((TextBox)Login1.FindControl("UserName")).Text; string pass = ((TextBox)Login1.FindControl("Password")).Text; if (CustomerDB.GetCustomerByEmail(user) != null) { Customer customer = CustomerDB.GetCustomerByEmail(user); Session["loggedin"] = true; Session["new"] = false; Session["customer"] = customer.CustomerID; Response.Redirect("~/CustomerInfo.aspx"); } else { Session["loggedin"] = false; Response.Write("<script>alert('Credentials Entered Incorrectly or do not exist!');</script>"); } }
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."; } }