Exemple #1
0
        public virtual ActionResult ChangePassword(GetNewPasswordViewModel model)
        {
            if (string.IsNullOrWhiteSpace(model.OldPassword))
            {
                // Old Password not entered. Just navigate to home page.
                ModelState.Clear();
                AddStatusMessage("Password not changed");
                return(RedirectToAction(MVC_DcmsMobile.Home.Index()));
            }

            if (!ModelState.IsValid)
            {
                // The passwords do not match. Ask for new password again.
                return(View(this.Views.GetNewPassword, model));
            }

            try
            {
                if (MembershipService.ChangePassword(this.HttpContext.User.Identity.Name, model.OldPassword, model.NewPassword))
                {
                    // This is the success case
                    this.AddStatusMessage("Your password has been changed");
                    return(RedirectToAction(MVC_DcmsMobile.Home.Index()));
                }

                // We should never get here
                this.ModelState.AddModelError("", "Your password could not be changed");
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError("", ex.Message);
            }

            // This is the error case
            return(View(this.Views.GetNewPassword, model));
        }
 public virtual ActionResult GetNewPassword()
 {
     var cpmodel = new GetNewPasswordViewModel();
     return View(this.Views.GetNewPassword, cpmodel);
 }
Exemple #3
0
        public virtual ActionResult GetNewPassword()
        {
            var cpmodel = new GetNewPasswordViewModel();

            return(View(this.Views.GetNewPassword, cpmodel));
        }
        public virtual ActionResult ChangePassword(GetNewPasswordViewModel model)
        {
            if (string.IsNullOrWhiteSpace(model.OldPassword))
            {
                // Old Password not entered. Just navigate to home page.
                ModelState.Clear();
                AddStatusMessage("Password not changed");
                return RedirectToAction(MVC_DcmsMobile.Home.Index());
            }

            if (!ModelState.IsValid)
            {
                // The passwords do not match. Ask for new password again.
                return View(this.Views.GetNewPassword, model);
            }

            try
            {
                if (MembershipService.ChangePassword(this.HttpContext.User.Identity.Name, model.OldPassword, model.NewPassword))
                {
                    // This is the success case
                    this.AddStatusMessage("Your password has been changed");
                    return RedirectToAction(MVC_DcmsMobile.Home.Index());
                }

                // We should never get here
                this.ModelState.AddModelError("", "Your password could not be changed");
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError("", ex.Message);
            }

            // This is the error case
            return View(this.Views.GetNewPassword, model);
        }