예제 #1
0
        public ActionResult ChangePassword(int userId, string returnUrl = "")
        {
            OnlyOwnerAccess(userId);
            User user = UserService.GetUserById(userId);
            var vm = new vmUser_ChangePassword
                         {
                             Credentials =
                                 {
                                     UserId = user.UserId,
                                     Username = user.UserName
                                 },

                             returnUrl = returnUrl
                         };
            return View(vm);
        }
예제 #2
0
 public ActionResult ChangePassword(vmUser_ChangePassword vm)
 {
     OnlyOwnerAccess(vm.Credentials.UserId);
     if (ModelState.IsValid)
     {
         if (!UserService.ValidateUser(vm.Credentials.UserId, vm.OldPassword))
         {
             ModelState.AddModelError("OldPassword", "Old Password Incorrect");
         }
         else
         {
             ServiceResult result = UserService.UpdatePassword(vm.Credentials.UserId, vm.Credentials.NewPassword);
             if (result.Success)
             {
                 DisplayMessageToUser(new DisplayMessage(DisplayMessageType.SuccessMessage,
                                                         "Password has been updated successfully"));
                 return RedirectToAction("EditUser", new { userId = vm.Credentials.UserId, returnUrl = vm.returnUrl });
             }
             Utilities.AddModelStateErrors(ModelState, result.GetServiceErrors());
         }
     }
     return View(vm);
 }