public ActionResult Change_Password(change_password password)
        {
            if (ModelState.IsValid)
            {
                if (password.new_password != password.confirm_password)
                {
                    ModelState.AddModelError(String.Empty, "New password and confirm password does not matched.");
                    return(View());
                }

                change_passwordMain main = new change_passwordMain();

                password.user_id = int.Parse(Request.Cookies["loginUserId"].Value);

                password.username = Request.Cookies["loginUserName"].Value.ToString();

                if (main.checkPassword(password) == 0)
                {
                    ModelState.AddModelError(String.Empty, "Old password is incorrect.");
                    return(View());
                }

                main.changePassword(password);

                return(View("success"));
            }
            return(View());
        }
Esempio n. 2
0
        public void changePassword()
        {
            AccessToSystem acc = new AccessToSystem();

            User.Check("Kornilov", "password");

            change_password form = new change_password();

            form.textBox1.Text = "pass";
            form.ChangePass();
            Assert.AreEqual(User.Check("Kornilov", "pass"), true);
        }
        public ActionResult Changepassword(change_password ch)
        {
            if (ModelState.IsValid)
            {
                //string password="";
                string user  = Membership.GetUser().ToString();
                string token = WebSecurity.GeneratePasswordResetToken(user);
                WebSecurity.ResetPassword(token, ch.newpassword);
                return(RedirectToAction("AdminDashboard"));
                //MembershipUser muser = Membership.GetUser(user);
                //string resetpassword = muser.ResetPassword();
                //muser.ChangePassword(resetpassword, ch.newpassword);
                //int userid=WebSecurity.GetUserId(user);

                //if (password == ch.oldpassword)
                //{
                //    string token = WebSecurity.GeneratePasswordResetToken(user);
                //    WebSecurity.ResetPassword(user, ch.newpassword);
                //}
            }
            return(View());
        }