Пример #1
0
        public async Task <ActionResult> ChgPwd(ChgPwd model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.UserId > 0 && db.ResUserDal.PrimaryGet(model.UserId) != null)
            {
                var newPassword = model.Password;
                var user        = APBplDef.ResUserBpl.PrimaryGet(model.UserId);
                var result      = await UserManager.ChangePasswordAsync(user.UserId, user.Password, newPassword);

                if (result.Succeeded)
                {
                    APBplDef.ResUserBpl.UpdatePartial(user.UserId, new { Password = newPassword });
                }


                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                ModelState.AddModelError("Password", "用户不存在");

                return(View(model));
            }
        }
Пример #2
0
        public async Task <ActionResult> ChgPwd(ChgPwd model)
        {
            var newPassword = model.Password;
            var user        = APBplDef.ResUserBpl.PrimaryGet(ResSettings.SettingsInSession.UserId);
            var result      = await UserManager.ChangePasswordAsync(user.UserId, user.Password, newPassword);

            if (result.Succeeded)
            {
                APBplDef.ResUserBpl.UpdatePartial(user.UserId, new { Password = newPassword });
            }

            return(RedirectToAction("Index", new { id = ResSettings.SettingsInSession.UserId, }));
        }