Exemplo n.º 1
0
        public ActionResult ChangePass(string oldpassword, string newpassword1, string newpassword2)
        {
            MembershipUser user = Membership.GetUser(this.User.Identity.Name);

            if (newpassword1 == newpassword2)
            {
                MembershipPasswordAttribute passcheck = new MembershipPasswordAttribute();

                if (passcheck.IsValid(newpassword1))
                {
                    if (user.ChangePassword(oldpassword, newpassword1))
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Old pass wrong");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "You need a stronger password");
                }
            }
            else
            {
                ModelState.AddModelError("", "New passwords dont match");
            }

            return(RedirectToAction("Index", "Home"));
        }
        public void FormatErrorMessage()
        {
            var passwordAttribute = new MembershipPasswordAttribute();

            Assert.AreEqual("The field testDisplay2 is invalid.", passwordAttribute.FormatErrorMessage("testDisplay2"));
        }
		public void FormatErrorMessage ()
		{
			var passwordAttribute = new MembershipPasswordAttribute ();
			Assert.AreEqual ("The field testDisplay2 is invalid.", passwordAttribute.FormatErrorMessage ("testDisplay2"));
		}