Ejemplo n.º 1
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                bool changePasswordSucceeded;
                try
                {
                    var command = new ChangePasswordCommand
                        {
                            UserName = User.Identity.Name,
                            OldPassword = model.OldPassword,
                            NewPassword = model.NewPassword
                        };

                    changePasswordSucceeded = mediator.Execute<ChangePasswordCommand, bool>(command);
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                    return RedirectToAction("ChangePasswordSuccess");

                ModelState.AddModelError("", "Either the current password or the new password is invalid.");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 2
0
        protected override void AfterSetUp()
        {
            base.AfterSetUp();

            Scenario = new LogOnScenario();
            Scenario.Populate(Session);

            Command = new ChangePasswordCommand
                {
                    UserName = Scenario.JohnDoe.UserName,
                    OldPassword = "******",
                    NewPassword = "******"
                };

            Handler = new ChangePasswordCommandHandler(Session);
        }