示例#1
0
        public ActionResult ResetPasswordConfirmed(string newPassword)
        {
            Guid resId = Guid.Parse(Session["ResId"].ToString());

            if (resId == null || String.IsNullOrEmpty(newPassword))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ResetPassword resPass = _resetPasswordManager.Find(x => x.Id == resId);
            var           userId  = resPass.ApplicationUserId;

            bool res = _userManager.ChangePassword(userId, newPassword);

            if (res)
            {
                resPass.IsUsed = true;
                int res2 = _resetPasswordManager.Update(resPass);

                // işlem başarılı
                Session.Remove("ResId");
                OkViewModel notifyObj = new OkViewModel()
                {
                    Title          = "İşlem Başarılı",
                    RedirectingUrl = Url.Action("Login", "Account")
                };
                notifyObj.Items.Add("Şifreniz değiştirildi. Giriş sayfasına yönlendirliyorsunuz.");

                return(View("Ok", notifyObj));
            }
            else
            {
                ModelState.AddModelError("", "İşlem başarısız");
            }

            return(View());
        }