Exemplo n.º 1
0
        public async Task <ActionResult> ResetPsw(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var accountComponent = new AccountComponent();
            var account          = await accountComponent.GetAccountByIdAsync(AccountInfo.Id);

            try
            {
                SecurityVerify.Verify <PasswordVerification>(account.Id.ToString(), account.Password, model.OldPassword);
            }
            catch (ApplicationException ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
            catch (Exception)
            {
                ModelState.AddModelError("", GeneralResource.SaveFailed);
                return(View(model));
            }
            await accountComponent.ResetPasswordAsync(account.Id, PasswordHasher.HashPassword(model.NewPassword));

            EmptyLoginInfo();
            ViewBag.PasswordHasSet = "1";
            ViewBag.PageName       = MerchantIndex.Pagename;

            return(View(model));
        }