Exemplo n.º 1
0
 //[Authorize]
 public ActionResult AdminChangePassword(Guid id)
 {
     MembershipUser member = Membership.GetUser(id, false);
     AdminChangePasswordModel model = new AdminChangePasswordModel();
     model.UserName = member.UserName;
     ViewBag.PasswordLength = MembershipService.MinPasswordLength;
     return View(model);
 }
Exemplo n.º 2
0
        public ActionResult AdminChangePassword(AdminChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                MembershipUser member = Membership.GetUser(model.id, false);
                if (member.ChangePassword(member.ResetPassword(), model.NewPassword))
                //if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword))
                {
                    levent.Level = LogLevel.Info; levent.Message = "Admin changed password for " + model.UserName;
                    log.Log(levent);
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError("", "Model validation error for Admin change password.");
                }
            }

            // If we got this far, something failed, redisplay form
            levent.Level = LogLevel.Info; levent.Message = "Password change failed for " + model.UserName;
            log.Log(levent);
            ViewBag.PasswordLength = MembershipService.MinPasswordLength;
            return View(model);
        }