Ejemplo n.º 1
0
        /// <summary>
        /// Matt Lapka
        /// Created 2015/04/30
        /// validates & sends updated password info to the BLL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChange_Click(object sender, EventArgs e)
        {
            //doublecheck client side validation
            if (txtNewPassword.Text.Trim() != txtNewPassword2.Text.Trim())
            {
                return;
            }
            if (!txtNewPassword.Text.Trim().ValidatePassword())
            {
                passRules.Visible = true;
                return;
            }
            passRules.Visible = false;
            PasswordManager myPass = new PasswordManager();
            string          pass   = myPass.supplierHash(_currentLogin.UserName, txtCurrent.Text);

            if (pass != _currentLogin.UserPassword)
            {
                lblError.Text = "Invalid Password";
                return;
            }
            lblError.Text = "";
            try
            {
                var result = _myMan.UpdateSupplierLogin(txtNewPassword.Text, _currentLogin);
                if (result == ResultsEdit.Success)
                {
                    _currentLogin.UserPassword = txtNewPassword.Text;
                    Session["login"]           = _currentLogin;
                    //show alert!
                    Response.Redirect("~/portal");
                }
                else
                {
                    Label errorLabel = (Label)Master.FindControl("lblErrorMessage");
                    errorLabel.Text = "Error Updating Password. Please try again.";
                    Control c = Master.FindControl("ErrorMess");
                    c.Visible = true;

                    return;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
 public void TestSupplierLoginUpdate()
 {
     setup();
     retrieveSupplier = access.RetrieveSupplierLogin("Password#1", "Test");
     Assert.AreEqual(ResultsEdit.Success, access.UpdateSupplierLogin("Password#2", retrieveSupplier));
 }