Exemple #1
0
        public ActionResult ChangePassword(ChangePasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = _userManager.Find(x => x.Id == CurrentSession.User.Id);
                if (Crypto.VerifyHashedPassword(user.Password, model.Password))
                {
                    user.Password = model.NewPassword;

                    BusinessLayerResult <AppUser> res = _userManager.ChangePasswordFromUser(user);
                    if (res.Errors.Count > 0)
                    {
                        res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                        return(View(model));
                    }
                    else
                    {
                        OkViewModel notifyObj = new OkViewModel()
                        {
                            Title          = "İşlem Başarılı",
                            RedirectingUrl = Url.Action("MyInfo", "Home")
                        };

                        notifyObj.Items.Add("Şifreniz değiştirilmiştir.");
                        return(View("Ok", notifyObj));
                    }
                }
            }

            return(View(model));
        }