Beispiel #1
0
        public async Task<ActionResult> SetPassword(SetPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword);
                if (result.Succeeded)
                {
                    var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                    if (user != null)
                    {
                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                    }
                    return RedirectToAction("Index", new { Message = ManageMessageId.SetPasswordSuccess });
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public void _SetPassword(SetPasswordViewModel model, string userguid)
        {
            if (!ModelState.IsValid)
            {
                this.AddToastMessage("",
                    model.ConfirmPassword != model.NewPassword ? "Parolalar uyuşmuyor." : "Alanları kontrol ediniz.",
                    Enum.ToastrType.Warning);

                return;
            }
            var user = UserManager.FindById(userguid);
            if (!UserManager.RemovePassword(user.Id).Succeeded) { this.AddToastMessage("", "şifre değiştirilirken hata.", Enum.ToastrType.Error); return; }
            var result = UserManager.AddPassword(user.Id, model.NewPassword);
            if (result.Succeeded)
            {
                this.AddToastMessage("", "Şifre Değiştirildi.", Enum.ToastrType.Success);
                return;
            }
            AddErrors(result);
        }