Esempio n. 1
0
        //[AllowAnonymous]
        public async Task <ActionResult> UpdatePassword(VM.UserInfoUpdatePassword modelNew)
        {
            if (modelNew.UserId != Convert.ToInt32(UserHelper.GetCurrentUser().Id))
            {
                return(Redirect(Url.Action("Index", "NoPermissions", new { area = "" })));
            }
            BL.UserInfo     empBL = new BL.UserInfo();
            VM.UserInfoItem model = new VM.UserInfoItem();
            // model.UserId = CommonMethod.getIntValue(UserHelper.GetCurrentUser().Id);
            model = empBL.GetItemById(model.UserId);
            IdentityModel user = await UserManager.FindByNameAsync(model.LogonName);

            //modelNew.Password = HashEncrypt.MD5(modelNew.Password);
            var results = await UserManager.CheckPasswordAsync(user, modelNew.Password);

            if (results)
            {
                //modelNew.NewPassword = HashEncrypt.MD5(modelNew.NewPassword);
                string    password = UserManager.PasswordHasher.HashPassword(modelNew.NewPassword);
                UserStore store    = new UserStore(UserHelper.GetCurrentUser().LogonName);
                var       set      = store.SetPasswordHashAsync(user, password);
                var       result   = store.UpdateAsync(user);
                if (user != null)
                {
                    return(Content("Success"));
                }
            }
            else
            {
                return(Content("Error"));
            }
            return(Content("False"));
        }
Esempio n. 2
0
        public ActionResult UpdatePassword()
        {
            ViewBag.ShowSubmit = true;
            BL.UserInfo empBL = new BL.UserInfo();
            int         id    = Convert.ToInt32(UserHelper.GetCurrentUser().Id);
            var         model = empBL.GetItemById(id);

            VM.UserInfoUpdatePassword updtaePassword = new VM.UserInfoUpdatePassword();
            updtaePassword.UserId = model.UserId;
            return(View(updtaePassword));
        }