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)); }
public async Task <ActionResult> FbPsw(FindBackPasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { SecurityVerify.Verify <FbPswEmailVerification>(model.Email.Replace("@", "_"), null, model.Code); } catch (ApplicationException ex) { ModelState.AddModelError("", ex.Message); return(View(model)); } catch (Exception) { ModelState.AddModelError("", GeneralResource.SaveFailed); return(View(model)); } var accountComponent = new AccountComponent(); var account = await accountComponent.GetAccountByEmailAsync(model.Email); if (account == null) { ModelState.AddModelError("", AccountFbPsw.EmailNotBind); return(View(model)); } if (account.Status != (byte)AccountStatus.Active) { ViewBag.PasswordHasSet = -1; return(View(model)); } await accountComponent.ResetPasswordAsync(account.Id, PasswordHasher.HashPassword(model.Password)); ViewBag.PasswordHasSet = 1; return(View(model)); }