예제 #1
0
        protected void LoginButton(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string hashedPswd = HashPassword.ApplyHash(txtModalCustPassword.Text);

                //string custEmail = String.Format("{0}", Request.Form["email_modal"]);
                //string custPassword = String.Format("{0}", Request.Form["password_modal"]);

                Customers custLogin = new Customers(txtModalCustEmail.Text, hashedPswd);

                string output = CustomersDB.GetCustomerLogin(custLogin);

                if (output == "1")
                {
                    Session["custEmail"] = txtModalCustEmail.Text;
                    Customers loggedCustomer = CustomersDB.GetCustomerbyEmail(Session["custEmail"].ToString());
                    Session["customerId"] = (int)loggedCustomer.CustomerId;

                    Response.Redirect("CustomerRegistration.aspx");
                }
                else
                {
                    Control loginFail = FindControl("LoginFailure");
                    loginFail.Visible = true;
                    string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Login failed, please check your credentials.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                }
            }
        }
예제 #2
0
        protected void LoginButton(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string hashedPswd = HashPassword.ApplyHash(txtModalCustPassword.Text);
                // string custEmail = String.Format("{0}", Request.Form["email_modal"]);
                // string custPassword = String.Format("{0}", Request.Form["password_modal"]);

                Customers custLogin = new Customers(txtModalCustEmail.Text, hashedPswd);

                string output = CustomersDB.GetCustomerLogin(custLogin);

                if (output == "1")
                {
                    Session["custEmail"] = txtModalCustEmail.Text;
                    Customers loggedCustomer = CustomersDB.GetCustomerbyEmail(Session["custEmail"].ToString());
                    Session["customerId"] = (int)loggedCustomer.CustomerId;

                    Response.Redirect("ItemsBought.aspx");
                }
                else
                {
                    Response.Write("Login Failed");
                }
            }
        }
예제 #3
0
        protected void DBPasswordValidator_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Customers isPasswordCorrect = CustomersDB.GetCustomerbyPassword(HashPassword.ApplyHash(txtOldCustPassword.Text));

            if (isPasswordCorrect == null)
            {
                args.IsValid = false;
                Control loginFail = FindControl("LoginFailure");
                loginFail.Visible = true;
                string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Unable to update password.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
            }
            else
            {
                args.IsValid = true;
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string hashedPswd = HashPassword.ApplyHash(txtCustPassword.Text);

                if (txtCustEmail.Text != "")
                {
                    Customers cust = new Customers(txtCustFirstName.Text, txtCustLastName.Text, txtCustAddress.Text, txtCustCity.Text, ddlCustProv.Text, txtCustPostal.Text, txtCustCountry.Text, FormatePhoneNo.ApplyFormatting(txtCustHomePhone.Text), FormatePhoneNo.ApplyFormatting(txtCustBusPhone.Text), txtCustEmail.Text, hashedPswd, "No");
                    try
                    {
                        int insertCustId = CustomersDB.AddCustomer(cust);
                        SendActivationEmail(txtCustEmail.Text);
                        Response.Redirect("ConfirmationPage.aspx");
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    string defaultEmail = "defaultemail" + CustomersDB.AssignEmailNo() + "@travelexperts.com";
                    Application["defaultEmail"] = defaultEmail;

                    Customers cust = new Customers(txtCustFirstName.Text, txtCustLastName.Text, txtCustAddress.Text, txtCustCity.Text, ddlCustProv.Text, txtCustPostal.Text, txtCustCountry.Text, FormatePhoneNo.ApplyFormatting(txtCustHomePhone.Text), FormatePhoneNo.ApplyFormatting(txtCustBusPhone.Text), defaultEmail, hashedPswd, "Yes");
                    try
                    {
                        int insertCustId = CustomersDB.AddCustomer(cust);
                        Response.Redirect("ConfirmationPageNoEmail.aspx");
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
예제 #5
0
 protected void btnUpdtPswd_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Customers loggedCustomer      = new Customers(Session["custEmail"].ToString(), HashPassword.ApplyHash(txtOldCustPassword.Text));
         Customers updatedPswdCustomer = new Customers(Session["custEmail"].ToString(), HashPassword.ApplyHash(txtNewCustPassword.Text));
         try
         {
             bool updatePswdSuccessful = CustomersDB.UpdateCustomerPassword(loggedCustomer, updatedPswdCustomer);
             if (updatePswdSuccessful)
             {
                 Control loginSuccess = FindControl("LoginSuccess");
                 loginSuccess.Visible = true;
                 string script = @"document.getElementById('" + LoginSuccess.ClientID + "').innerHTML='Password update successful.' ;setTimeout(function(){document.getElementById('" + LoginSuccess.ClientID + "').style.display='none';},5000);";
                 //Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Show status", script, true);
             }
             else
             {
                 Control loginFail = FindControl("LoginFailure");
                 loginFail.Visible = true;
                 string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Unable to update password.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                 //Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Show status", script, true);
             }
         }
         catch (Exception)
         {
             ExceptionScript();
         }
     }
 }